React icon workflow
SVG to React icon component
A good SVG to React icon component is small, readable, labelled correctly, and safe to reuse more than once on the same page.
SVG to React icon component conversion is useful when you have one icon or logo mark that needs to live in a React app. The converter handles common JSX attribute changes, but you still need to review naming, duplicate IDs, styles, and accessibility labels.
React icon component checklist
- Clean the SVG first if it came from an unknown source.
- Use a clear PascalCase component name, such as
SearchIconorCameraIcon. - Check converted JSX attributes like
strokeWidth,fillRule, andclassName. - Review IDs if the icon uses gradients, masks, clip paths, or filters.
- Decide whether the icon is decorative or meaningful before adding labels.
A simple TSX pattern
For app icons, a typed component can accept normal SVG props. That keeps size, className, aria labels, and event handlers under the control of the place where the icon is used.
import type { SVGProps } from "react";
export function SearchIcon(props: SVGProps<SVGSVGElement>) {
return (
<svg viewBox="0 0 24 24" role="img" {...props}>
<path d="M10 18a8 8 0 1 1 5.3-14" />
</svg>
);
} When to use PDFSVG instead of SVGR
Use PDFSVG when you need a quick browser conversion for a single SVG and want to inspect the output right away. Use SVGR when your project needs repeatable import rules, build integration, icon templates, and shared settings across many files.
Clean before converting unknown SVG
Design tools can export metadata, inline styles, scripts, event handlers, and IDs that make React icons harder to maintain. Run unknown SVG through cleanup first, then convert it to a component once the browser preview looks right.
Common questions
How do I convert SVG to a React icon component?
Paste or load the SVG, choose a component name, convert the markup, then review JSX attributes, IDs, labels, and styles before using the component.
Should React SVG icons use TypeScript props?
A common pattern is SVGProps<SVGSVGElement>. It lets the icon accept size, className, aria labels, and other SVG attributes from the parent component.
Should I clean SVG before making a React component?
Yes when the SVG came from an unknown source or a design export. Cleanup removes risky or noisy markup before JSX conversion.
Is PDFSVG a replacement for SVGR?
PDFSVG is best for quick one-off conversion in the browser. SVGR is better for repeatable project build workflows and large icon sets.