Repository navigation
FAQ
SVGR turns an SVG into a component too. This tool does that for a whole folder of SVGs and adds what an icon set needs: a prop per colour (colors, opacities, strokeWidths), a typed registry with a lazy Icon, names made from the folder structure, cleanup, and a --check for CI. If you need one component from one SVG, SVGR is enough.
An icon directly in the input folder has no variant, so it takes the input folder's own name. With input: icons it is icons.camera; with input: assets/exported it is exported.camera. Put icons in a variant folder to choose the name. See Naming.
colors={[undefined, "red"]}. A hole falls back to fill/stroke, then color, then currentColor. Which slot is which is written at the top of the generated file (Components).
SVGO runs first and shortens colours. The list shows what is left after it.
The icon components have no hooks or state and can render on the server. icon.tsx starts with "use client" because it uses React.lazy and Suspense with a client-side import; import the components directly in a server component.
So that they are the same files your own formatting would leave. Without it, a lint-staged run would change every generated file at commit time and --check would never pass. Set format: false to write the raw text.
Nothing. Only a .ts or .tsx file that carries the tool's banner and that a run no longer produces is deleted.
The registry is always lazy, but nothing makes you use it: import a component from its variant folder (./generated/bold) and it is a normal static import.
The component has one strokeWidth, with strokeWidths per colour slot. The width written in the SVG is removed from the shapes and the most common one becomes the default. See Input-Format.
Every dependency runs on older versions; Node 20 is the oldest the tests run on.