How to export a Framer component or section as React code

By Jake Marsh · Updated

To export a Framer component or section as React code, select the frame, text or component on the canvas, open Sourceferry and click its Selection tab. Choose Next.js (React, TypeScript) under Format, then click Copy code to put the React component and its CSS on your clipboard, or Download ZIP to get them with the layer's images and any design components it uses. Choose Static HTML and CSS for an HTML snippet instead.

When one layer is the right size

  • A pricing table, hero or footer designed in Framer that's needed inside an existing React or Next.js app.
  • A card component you'll turn into a real component with props.
  • An HTML block for an email-safe landing page or a CMS that accepts raw HTML.

For whole pages, export the site instead: see how to export a Framer site to a Next.js project.

Steps

  1. Select a layer on the canvas: a frame, a stack, a text layer or a component instance. The Selection tab shows "Selected:" with its name.
  2. Pick a Format. Next.js (React, TypeScript) gives "A React component and its CSS." Static HTML and CSS gives "An HTML snippet and its CSS."
  3. Click Copy code, and paste into your editor. If the browser blocks the clipboard, Sourceferry says so; use Download ZIP instead.
  4. Or click Download ZIP. It includes the code, the layer's images and every design component it uses.
  5. Paste the CSS into your stylesheet, or import it next to the component.

What the code looks like

  • Class names come from your layer names. A stack called "Pricing card" with a text called "Price" gives classes you can recognize, instead of numbered divs.
  • Stacks become flexbox with their direction, gap, padding and alignment; grids become CSS grid with their columns and spans.
  • Breakpoints become media queries, so a layer you hid on phones stays hidden on phones.
  • Color styles become CSS variables, and text styles become classes with their heading tags.
  • Images keep their alt text.

Components inside the selection

Design components from your project come out in their primary variant, as their own component in React or inlined in HTML. The values set on a particular instance aren't applied, so give the component props for those in code. Code components and components from other projects get a placeholder element with the component's name and Framer URL.

What doesn't come with it

Shadows, blurs, interactions, animations and hover states aren't readable through Framer's plugin API, so add them in CSS or your animation library. The report in the ZIP names each layer that lost something.

What it costs

On the trial, a selected layer counts as one of 5 exports over 7 days, with no card. After that Sourceferry is $59 a month, $499 a year or $799 once per seat. Plans are on the Sourceferry page.

Sourceferry

Export a Framer project as code you edit: a static HTML and CSS site or a Next.js project, built from the canvas inside the plugin, with breakpoints, styles, images, fonts and CMS content $59 a month or $499 a year per seat, or $799 once.


Questions

Does it work with Framer Motion?

The exported component is plain React and CSS. Animations from Framer aren't exported, so if you want them, add Framer Motion or another library yourself.

Can I export a component with all its variants?

No. A design component comes out in its primary variant. Other variants are something you'd add as props or classes.

Does Copy code count against the trial?

Yes. Copying or downloading a selected layer is one export.

Is the code TypeScript?

In the Next.js format, yes: a React component in TypeScript. The HTML format gives an HTML snippet.


More Sourceferry guides


More Framer guides