Skip to content

Search

Articles, tools, solutions and knowledge base guides

Start typing to search across articles, tools and apps.

SVG to React component

MEMBERS

Turn an SVG into a JSX or TSX component with the right attribute names, style objects and passed props, without its scripts.

Free to use Files need an account Privacy protection

Canvas

Canvas

100%

Press an element to select it, arrows move it, Delete removes it, Ctrl D copies it. V selects, A edits points, P is the pen, R a rectangle, O an ellipse, T a text. Layers hold every element for the keyboard.

Code, live both ways

Code, live both ways

Weight

What the file weighs

    All optimizations

      Export

      Scripts, event handlers and outside resources are left out of every file.

      Pictures

      Code

      Saved work and templates

      On this device

      Nothing has been saved yet.

        Templates

        Found a bug or missing something? Write to us

        How it works

        A component you can commit

        Attributes get the names React expects, class becomes className, and a style attribute becomes an object. Props are spread on the root, so size, colour and handlers are passed from outside.

        Scripts, event handlers, editor data and outside addresses are left out, because a component runs inside your application. Style sheets inside the file are kept as a string.

        The name of the component comes from the title of the drawing. Optimize first to make it shorter; use currentColor in the drawing to let the text colour paint the icon.

        Help

        FAQ

        Is the component a default or a named export?

        A named export, export function Name(props), imported as import { Name } from './Name'. The typed version adds import type { SVGProps } from 'react' and gives props the type SVGProps<SVGSVGElement>, so every attribute of svg is checked.

        How are xlink:href, aria and data attributes converted?

        xlink:href becomes href, xml:space xmlSpace and tabindex tabIndex, and other hyphenated names such as stroke-width are joined into strokeWidth. aria- and data- attributes keep their hyphens, as React expects, and the namespace declarations of drawing programs are left out.

        Is a component better than an img with an SVG file?

        A component is drawn inside the page, so CSS and currentColor reach every path and props change it, but its code goes into the JavaScript of every page that uses it. An img with a .svg file is cached on its own and cannot be styled from outside, which suits large illustrations.

        Opening files needs an account

        Typing and pasting work without an account. To open or drop a file, sign in to your POLPROG account or create one in under a minute. Files are still processed only in this browser.

        • Secure access
        • Account in under a minute