# SVG to React

Turn an SVG file into a React component. The tool converts attributes to their React names, such as stroke-width to strokeWidth and xlink:href to xlinkHref, turns style attributes into objects, drops the XML declaration and comments, and can pass the component props to the svg element with a TypeScript SVGProps type.

## Frequently asked questions

### What does the generated component look like?

A default exported function component that returns the svg element. With Pass props on, it accepts props and spreads them onto the svg, so you can set className, width, height or aria attributes where you use it.

### Which attributes are converted?

Hyphenated presentation attributes such as stroke-width, fill-rule and stop-color become camelCase, xlink:href becomes xlinkHref, xmlns:xlink becomes xmlnsXlink and class becomes className. Attributes that are already camelCase in SVG, such as viewBox, keep their name.

### Is the SVG optimized?

No. The tool keeps every element and attribute except the XML declaration, the doctype and comments. Run the SVG through the SVG Minifier first if you want smaller markup.

### Can I use it without TypeScript?

Yes. Turn off TypeScript props type to get a plain JavaScript component without the SVGProps import.

### What if my file contains several SVG elements?

The input must have exactly one svg root element. Split files with several root elements and convert each one.

### Are width and height removed?

No. They are kept as written. Because props are spread after the original attributes, a width or height you pass to the component overrides them.

Your ad here?

[Email us](mailto:hi@dennn.is?subject=Advertising%20on%20OneClick%20Pro)

[Ad 433 tools for your AI agents through one MCP server.](https://multitaskai.com/?ref=oneclickpro)
