@mrzr/react-svg-icons
A folder of SVGs to typed React components.
Every icon becomes a typed TSX component with props for its size and each of its colours, plus a lazy-loaded Icon with a typed name.
npm install --save-dev @mrzr/react-svg-iconsnpx @mrzr/react-svg-icons# react-svg-icons.config.yaml
# input: icons
# outDir: generated
npx @mrzr/react-svg-icons # writes the components into generated/
npx @mrzr/react-svg-icons --check # exit 1 when they are out of dateimport { Icon } from "./generated";
import { Logout } from "./generated/bold";
<Icon name="bold.logout" size={20} />
<Logout size={20} color="crimson" />What it does
A component per SVG
Optimised with SVGO, with a forwarded ref.
Props for every colour
size, color, stroke, fill, strokeWidth, opacity, title, and per-path colors, opacities and strokeWidths.
A typed Icon name
name="bold.logut" is a type error, and each icon loads as its own chunk.
Your formatting, your CI
Output runs through your own prettier, --check fails stale output, and removed SVGs are cleaned up.
Documentation
Everything is documented.
More in design pipeline