Loading

Seamless SVG workflow

Stas Gavrylov

This is a live streamed presentation. You will automatically follow the presenter and see the slide they're currently on.

Stas Gavrylov

@stasgavrylov

Lead Frontend Engineer @ Rails Reactor

Seamless SVG workflow
in
create-react-app

without
eject
ing

Problem

pencil.svg

Solutions

Option 0: <img> tag

Solutions

Option 1: Duplicate files

Solutions

Option 2: Inline SVGs

Solutions

Option 3: Icon Font

Solutions

Option 4:

"npm run eject" + some-svg-loader

Solutions

Option 5: SVG Sprites

svg-sprite
+
svg4everybody
+
<use>

svg-sprite
  1. Supports different outputs, uses SVGO, highly configurable
  2. File names will become IDs
  3. Remove FILL and STROKE attributes from SVGs in advance
svg4everybody

Adds external SVG support for all browsers

<use> element

Simplest use case

<SVGIcon /> (code)
SvgIcon.css
App.js

Links

Made with Slides.com