Figma icons to React components: export SVGs, run SVGR

Turn Figma icons into React components: prepare and name the icons, batch-export clean SVGs, run the SVGR CLI, then set currentColor and accessible labels.

By UIXport team10 min read
On this page

Key takeaways

  • Figma and UIXport give you SVG files. SVGR, a separate open-source tool, turns those files into React components. UIXport does not write React code.
  • Prepare every icon on one frame size, with no frame fill, center or outlined strokes and a single colour, so one rule can later swap that colour for currentColor.
  • Name icon frames in lowercase with hyphens, such as arrow-left. The SVGR CLI turns arrow-left.svg into an ArrowLeft component.
  • In UIXport's Exporter, set the Export as row to SVG, keep Clean SVG Markup (Remove Figma properties) on and keep the {frame} naming pattern. SVG is always 1x and text is outlined.
  • Hide decorative icons with aria-hidden="true" and put the accessible name on the button or link, not inside the SVG.

Short answer: To turn Figma icons into React components, export each icon as an SVG file, then run SVGR, an open-source tool that converts SVG files into React components. Before you export, put every icon in a frame of the same size, use one colour and name the frames the way you want the components named. After converting, swap that colour for currentColor and put labels on the buttons, not on the icons.

You have two dozen icons in Figma and a React app that needs them, and nobody wants to paste <svg> blocks into JSX by hand. Here is a pipeline that holds up: tidy the icons in Figma, export clean SVGs in one batch, and let SVGR write the components.

What does the Figma-to-React icon pipeline look like?#

There are four stages: prepare the icons in Figma, export them as SVG files, convert the files with SVGR, then handle colour and accessibility in your code.

Stage Where it happens What you get
Prepare Figma Icon frames of one size, in one colour, with code-friendly names
Export Figma's own export or UIXport One .svg file per icon
Convert SVGR CLI One React component per icon, plus an index file
Use Your codebase Icons that follow currentColor and sit inside labelled controls

SVGR describes itself as a way to transform SVGs into React components (SVGR: getting started). We use its command-line tool here.

Still choosing between components, a sprite and an icon font? Icon font vs SVG sprite vs inline SVG compares them.

How should you prepare icons in Figma?#

Give every icon the same frame size, no frame fill, center or outlined strokes and a single colour. These habits decide whether a whole set of components behaves the same in code.

  • One frame size. Put each icon in a frame of the size your code expects, usually 24 × 24, and export the frame, not the shapes inside it. Every file then has the same canvas, and icons line up without per-icon CSS.
  • No fill on the frame. Remove any fill from the icon frame, or it can come out as a coloured square behind the drawing. Open one exported file to check.
  • Center strokes, or outlined ones. Figma's help says the SVG format only supports center strokes (Figma help: stroke properties). Set strokes to center, or use Outline stroke from the right-click menu to turn the stroke into a vector object.
  • Fewer layers. Flatten combines the selected layers into a single layer (Figma help: convert text to vector paths), which usually means fewer groups and paths in the file. It is destructive, so keep an editable copy on another page.
  • One colour. Use a single colour for every fill and stroke, ideally the same one across the set. Later, one rule swaps that exact value for currentColor.
  • No live text. UIXport outlines text in every SVG, as does Figma's Outline text setting (Figma help: export settings), so letters arrive as paths.

How should you name icons for code?#

Name each icon frame the way you want the file named: lowercase words joined by hyphens, such as arrow-left, chevron-down or close. SVGR's CLI turns file names into PascalCase, so arrow-left.svg becomes an ArrowLeft component.

The SVGR CLI docs show icons/web/clock-icon.svg coming out as dist/web/ClockIcon.js, folders kept. The default index file adds an Svg prefix when a name starts with a digit, so keep numbers away from the front.

  • Treat names as an API. Once a developer imports ArrowLeft, renaming the Figma frame renames the component and breaks that import.
  • Leave size out of the name unless the code needs separate drawings. search-16 and search-24 make two components, where one search sized with CSS is often enough.
  • Watch slashes and spaces. In Figma's bulk export, slash-separated names become nested folders (Figma help: guide to exports), and UIXport keeps forward slashes in file names too. A component called Icon / Arrow left brings slashes and spaces into your paths, so rename it to arrow-left first.

To fix names at the source, use UIXport's Asset finder: click a card's name and the layer is renamed in Figma, as its own undo step. Clicking a name in the Exporter list changes only the output file name.

Steps to export clean SVGs in one batch#

In UIXport's Exporter, select the icon frames, set the format row to SVG, keep the cleanup toggle on and keep the {frame} naming pattern. More than one icon arrives in a single ZIP.

  1. Select the icons. Select the icon frames on the canvas and open UIXport. They appear in the Exporter list, each checked, with its size shown as W×H. If one icon shows 25×24, fix it now.
  2. Set the format. In the Export as card, change the row's format from PDF to SVG. Leave the scale alone, because SVG always exports at 1x.
  3. Keep the cleanup on. Open Advanced settings and check that Clean SVG Markup (Remove Figma properties) is on. It runs SVGO's default preset over every file and keeps the viewBox.
  4. Keep the name. Leave Naming Pattern at {frame}, so the arrow-left frame exports as arrow-left.svg. Don't put {index} first, or every file name starts with a number.
  5. Name the archive. Under Archive settings, type a ZIP archive file name such as icons-svg. Otherwise the set arrives as UIXport Export.zip.
  6. Export. Click Export Selected (N Formats) and unzip the files into a folder in your repository, such as assets/icons.

To be fair to Figma: its own SVG export is a perfectly good input, since SVGR cleans files again. For one or two icons, it is quicker to right-click, choose Copy/Paste as > Copy as SVG (Figma help: guide to exports) and paste the markup into the SVGR playground. UIXport helps when you want format, names and ZIP set in one panel, cleaned SVGs in the repository, and a scan across every page. The SVG export and batch export pages have the details, and naming patterns lists every token.

How do you turn SVGs into React components with SVGR?#

Install the SVGR CLI in your project and point it at the folder of SVG files. It writes one component per file plus an index file to import from.

bash
npm install --save-dev @svgr/cli
npx @svgr/cli --icon --out-dir src/icons -- assets/icons

Then import by name:

jsx
import { ArrowLeft, Close } from './icons';

These options matter most for icons, as described in the SVGR options docs in October 2026:

Option CLI flag What it does
icon --icon Replaces the SVG's width and height. With no value it uses 1em, so the icon sizes with the surrounding text
typescript --typescript Writes .tsx files with typings
replaceAttrValues --replace-attr-values Replaces attribute values, for example a hex colour with currentColor
titleProp --title-prop Adds a title prop that renders a <title> element
svgo --no-svgo SVGO runs before each component is built. This flag turns it off

SVGR also reads a .svgrrc file, in JSON or YAML (SVGR configuration files):

json
{
  "icon": true,
  "typescript": true,
  "replaceAttrValues": { "#1e1e1e": "currentColor" }
}

Save the CLI command as a script in package.json, and regenerating the set is one command.

How do you make icon colour follow currentColor?#

Replace the icon's single colour with currentColor. The icon then takes the text colour of whatever contains it, so a button with red text gets a red icon with no extra CSS.

currentColor is a CSS keyword that stands for the value of an element's color property (MDN: currentColor). SVG's fill and stroke accept it too (MDN: SVG color attribute), so fill="currentColor" paints the shape in the inherited text colour.

The direct route is SVGR's replaceAttrValues:

bash
npx @svgr/cli --icon --replace-attr-values "#1e1e1e=currentColor" --out-dir src/icons -- assets/icons

It replaces attribute values, so it covers outlined icons that use stroke as well as solid icons that use fill.

The value has to match what SVGR sees after its own SVGO pass, which runs first. That pass can rewrite a raw Figma colour, for example #FFFFFF to #FFF, and a value that no longer matches is skipped without a warning. A UIXport-cleaned file is already in the lowercase, shortest form that SVGO's convertColors writes by default (SVGO: preset-default, SVGO: convertColors), so #1E1E1E in Figma is #1e1e1e in the file. Either way, open one generated component after the first run. If it doesn't say currentColor, copy the colour from it into the flag.

For sets where every icon is strictly one colour, convertColors also has a currentColor option you can turn on in an svgo.config.js, which is where SVGR recommends you configure SVGO. That file replaces SVGR's SVGO settings, so also set removeViewBox: false in the preset's overrides, and add prefixIds if your icons use ids.

Two-tone icons need more planning, such as keeping the second colour fixed or swapping it for a CSS variable. Decide that in Figma, before you export.

How do you make React icons accessible?#

Hide decorative icons with aria-hidden="true" and give the button or link its accessible name. Don't rely on a <title> inside the SVG to name a control.

Sara Soueidan's guide to accessible icon buttons recommends three ways to name an icon button: visually hidden text inside it, aria-labelledby pointing to hidden text, or aria-label on the button. She advises against naming the button through the SVG, because those techniques fail in some browser and screen reader combinations. Her examples also add focusable="false" to the <svg>, which only matters in Internet Explorer.

SVGR passes props through to the <svg> by default, so you can add aria-hidden where you use the icon:

jsx
// Icon next to visible text
<button type="button">
  <Search aria-hidden="true" />
  Search
</button>

// Icon-only button
<button type="button" aria-label="Close">
  <Close aria-hidden="true" />
</button>

How do you keep the icon set in sync with Figma?#

Treat Figma as the source and the components as generated output. When an icon changes, re-export it under the same name, replace the SVG and run SVGR again.

  • Re-export only what changed. Select the edited frames, export, and overwrite the old files.
  • Don't hand-edit generated components. A rerun writes over them, so a manual fix disappears. Put changes in .svgrrc, or fix the drawing in Figma.
  • Commit the SVG files. A reviewer then sees the drawing change next to the component change.
  • Look for duplicate names. When two files in a UIXport ZIP share a name, the second gets (1) added, as in close (1).svg. Rename one of the frames before it becomes a component.

To trim the files further before they reach SVGR, how to make Figma SVG exports smaller covers what cleanup removes and what to fix in the drawing.

Try UIXport from Figma Community and export your next icon set as clean SVGs that SVGR turns into components in one command.

Questions

Can UIXport export React components from Figma?

No. UIXport exports SVG files, cleaned with SVGO by default, and a tool such as SVGR turns those files into React components.

Do I need to clean SVGs before running SVGR?

Not strictly, because SVGR runs SVGO by default before it builds each component. Cleaning at export still helps, since the SVG files you commit are smaller and easier to read in a code review.

How do I make a Figma SVG icon use currentColor?

Draw the icon in one colour, export it, then replace that colour with currentColor. With the SVGR CLI, pass --replace-attr-values with the colour as SVGR's own SVGO pass writes it, an equals sign and currentColor. Open one generated component to check that it says currentColor.

Why do my exported icons come out at different sizes?

You probably exported the shapes rather than a frame around them. Put every icon in a frame of the same size, such as 24 by 24, and export the frames.

Should an icon-only button use the SVG title as its label?

No. Sara Soueidan notes that names given only through the SVG fail in some browser and screen reader combinations. Put aria-label or visually hidden text on the button, and aria-hidden="true" on the icon.

How many icons can I export on UIXport's Free plan?

As many as you like. SVG export has no cap on the Free plan. Turning icons into React or Vue components in Dev tools is a Pro feature, with 10 free Pro runs a month on Free.

Features in this post

Share this post

Share on XShare on LinkedIn

UIXport team

We build UIXport, the Figma plugin for exporting, compressing and delivering UI assets, at Sigma Studio.

About UIXport

Try it in Figma

Install the plugin from Figma Community. Free includes unlimited core exports and 10 Pro runs a month; Pro adds motion export, print-ready PDFs, AVIF and more.