All posts
Product design

Component Library Design in Figma: Variants, Properties and Auto Layout

How to build a Figma component library whose variants, properties and auto layout mirror React props, so design-to-code handoff becomes one-to-one.

By Mehdi Hassan7 min read

The short answer

To build a Figma component library, start from tokens, build each component with auto layout, and give it the same properties its React version will have: variants for size and style, booleans for optional parts, text properties for labels and instance swaps for icons. When Figma properties mirror code props, handoff stops being translation.

Key takeaways

  • Design each Figma component's properties as if you were writing its React props, with the same names and options.
  • Variants are for values that change appearance (size, style, state). Booleans and instance swaps handle the rest.
  • Build with auto layout and tokens only. A component with fixed widths or raw hex values isn't ready for code.
  • Interactive states like hover, focus and disabled belong in variants so developers can see every one.
  • Start with a small core set of components. Add new ones when real screens need them, not in advance.

Part of Design Systems for Startups: What You Need, When and How to Build One

How do you build a component library in Figma?

You build a Figma component library in a dedicated library file, on top of variables, one component at a time, in the order your product uses them. Each component gets auto layout, token-based styling and a property panel that matches how the coded component will be configured. Then you publish it so product files use instances instead of copies.

The angle that makes a library useful rather than pretty is parity with code. If the Figma button has a variant called Type with options Primary and Ghost, and the React button has a prop called variant with options primary and ghost, a developer reads the design and knows exactly what to write. That parity is the core of a working system, as our guide to design systems for startups explains.

How do Figma component properties map to React props?

Figma's component properties map almost directly to React props. Variants become enum props, boolean properties become boolean props, text properties become string props or children, and instance swap properties become component or icon props. Treat the Figma property panel as the component's API.

Figma property

Use it for

React equivalent

Example

Variant

Options that change appearance

Enum prop

size: sm, md, lg

Boolean

Showing or hiding a part

Boolean prop

hasIcon, isLoading

Text

Editable labels

String prop or children

label, helperText

Instance swap

Swappable icons or sub-components

Component or icon prop

icon: Plus, Search

Nested instance (exposed)

Configuring a child from the parent

Props passed through to a child

Avatar size inside a list item

Variable mode

Theme or density context

Context provider or data attribute

Dark mode, compact density

Name properties the way engineers will. If code uses size and variant, don't call them Scale and Kind in Figma. Agree on the names before building the first component, and write them in a shared table. Later, Figma Code Connect can map these properties to real code snippets in Dev Mode, but only if the two APIs already line up.

What should a Figma component library include first?

A Figma component library should start with the small set of components that appear on almost every screen. For most products that's form controls, buttons, feedback elements and a couple of layout containers. Build them well, with every state, before adding anything specialized. The list below is the pool to pick from, not a quota: start with the ones your screens actually use.

  • Actions: button, icon button, link.
  • Form controls: text input, textarea, select, checkbox, radio, switch.
  • Feedback: badge, toast, inline alert, tooltip.
  • Containers: card, modal or dialog, popover or dropdown menu.
  • Navigation: tabs, sidebar item, breadcrumb.
  • Data: table cell and row, empty state, skeleton.

Data-heavy products should prioritize the table early. It's usually the most complex component and the one most likely to be designed differently on every screen. Our SaaS dashboard design checklist covers what a good table needs.

How do you build one component step by step?

Build each component the same way, so the library stays consistent and developers learn one pattern. Here is the order we use, shown for a button.

  1. Write the API first

    List the props in a note next to the component: variant (primary, secondary, ghost, destructive), size (sm, md, lg), state (default, hover, focus, disabled, loading), iconLeft, iconRight, label. This list is the contract with code.

  2. Build the base with auto layout

    Create a frame with horizontal auto layout, padding from spacing variables, a gap token between icon and label, and hug contents width. See our guide to Figma auto layout for how these settings match CSS flexbox.

  3. Apply tokens only

    Fill, stroke, radius, padding and text color all use semantic variables. No raw values. This is what lets one component work in light and dark mode.

  4. Add properties

    Add a text property for the label, boolean properties for each icon slot, and instance swap properties so designers pick icons from the library's icon set.

  5. Combine variants

    Create variants for variant, size and state. Name the variant properties exactly like the props you wrote down. Only make a variant when the appearance actually changes.

  6. Document and publish

    Add a short description with usage notes and a link to the code component, then publish the library update with a change note.

How should you handle states and edge cases in components?

Handle states inside the component as variants, so every state a developer must build is visible in one place. At minimum that's default, hover, focus, disabled and, for anything async, loading. Inputs also need filled, error and read-only.

Edge cases are where handoff usually breaks. Show what happens with a very long label, a missing image, a zero count and a truncated name. Put these on a documentation frame next to the component rather than as extra variants. Our Figma handoff checklist lists the states developers most often find missing.

Hypothetical example: one table row, built for parity

For example, suppose a product has a users table. In Figma, the row component has variants for density (compact, comfortable) and state (default, hover, selected), a boolean for showing the checkbox column, and a nested avatar instance exposed so its size can be set from the row.

In React, the row takes density, isSelected and selectable props and renders the same avatar component. Hover isn't a prop because CSS handles it, so the Figma hover variant is documented as visual only. A developer looking at any table in the product files can read the row instance's properties and write the matching JSX without asking a question.

How do you organize and maintain a Figma component library?

Organize the library by component category, one page per group, with a cover page and a changelog. Keep the library file separate from product files, and make it the only place components are edited.

Pros

  • Product designers build screens from instances, so fixes update everywhere
  • Developers read props from the property panel instead of guessing
  • New designers learn the product's patterns from one file
  • Code Connect and AI tools work far better with consistent component APIs

Cons

  • A library needs an owner, or it drifts away from code
  • Publishing changes can break detached or overridden instances
  • Too many components make the asset panel hard to search
  • Parity with code needs regular checks as both sides change

If your team also maintains a marketing site, its section components follow the same rules but serve a different user, the marketer editing a CMS. Our guide to page builder blocks covers that version. The tokens underneath both should be the same Figma variables.

When is a Figma component library ready for developers?

A Figma component library is ready for developers when every component uses only tokens and auto layout, every property matches a code prop by name, and every state is drawn. If any of those three fails, developers will invent the missing parts and the build will drift from the design.

We build libraries this way because our designers and developers are the same team, so we feel any mismatch immediately. If you want a brand refresh or redesign explored in Figma first, our brand and design sprint is $3,000, fixed. See what's included on our pricing.

Frequently asked questions

What's the difference between variants and component properties?
Variants are a type of component property. They group several versions of a component, like sizes or states, into one component set. Other component properties are boolean, text and instance swap, which change parts of a single component without creating new versions. Use variants for appearance changes and the other property types for optional parts, labels and icons.
Should I use a UI kit or build my own Figma component library?
Start from a UI kit if it matches the component library your code uses, such as a shadcn/ui kit for a shadcn codebase. Then rename properties and variables to match your code and restyle with your tokens. Building from scratch only makes sense when your components are genuinely custom or no kit matches your code.
How many components does a startup's Figma library need?
Fewer than most teams build. A small set of well-made core components covers most screens in an early product: buttons, form controls, feedback elements, cards, dialogs, tabs and a table. Add specialized components when a real screen needs them, and only once you've confirmed the pattern will be reused.
Should every icon be a separate component?
Yes. Each icon should be its own component in an icon set, on a consistent frame size, with its color tied to a variable. That lets designers use instance swap properties to pick icons inside buttons, inputs and menus, and it maps cleanly to an icon prop or component in code.
How do I keep a Figma library in sync with the coded components?
Give one person ownership of both sides, review library changes and code changes together, and keep a shared table of component names and props. Tools like Code Connect make the link visible in Dev Mode. A regular design QA pass comparing production with the library catches drift before it spreads.

· CEO & Design Director

Copywriter, designer and developer, and founder of Designify Studio. Over five years, 60+ projects across 14+ industries, for startups that have raised $300M+.

Want this done for you? Brand & design sprint, $3,000.

A brand refresh or redesign, plus design explorations for your website and product. $3,000, one-time, fixed price. Book a free 30-minute call to see if it fits.

Schedule Call