EduFlow
UI Design with Figma
0%

Section 3 · Components and Systems

Variants and Component Properties

20 min3 min readPut in order

Lesson at a glance

Combine related components into a variant set with clear property names, then add boolean, text and instance swap properties so Steady’s button and habit row stay small and easy to use.

  1. 1Variants: one set, many versions
  2. 2Component properties: switches without multiplication
  3. 3Build order matters

No video here — just the real thing: a written lesson, runnable examples, a quiz and practice.

Steady’s primary button looks simple until you list what it needs: a primary, secondary and ghost type; default, pressed and disabled states; medium and small sizes; an optional icon; and any label. Build each of those as a separate component and you have dozens of near-copies, and a designer choosing between Button Primary Small Disabled With Icon and its neighbours.

Variants and component properties turn that pile into one component with a few clear switches.

Variants: one set, many versions

A component set holds related components called variants. Each variant is described by variant properties, written as Property=Value pairs. For Steady’s button:

  • Type: Primary, Secondary, Ghost
  • State: Default, Pressed, Disabled
  • Size: Medium, Small

You create variants either by selecting several existing components and clicking Combine as variants, or by selecting a component and adding a variant from the right sidebar, then renaming the properties and values. Figma treats the variant at the top-left of the set as the default.

On an instance, people no longer hunt through assets. They place one Button and pick values from dropdowns: Type Secondary, State Disabled. The names you choose here are the names developers will see in Dev Mode, so make them match code where you can. If the code says variant="secondary", consider calling your property Variant rather than Type, and agree on it with engineering early.

A three-by-three grid of button variants. Columns are the states Default, Pressed and Disabled; rows are the types Primary, Secondary and Ghost. A dashed border surrounds the whole set. Default Pressed Disabled Primary Secondary Ghost Save habit Save habit Save habit Save habit Save habit Save habit Save habit Save habit Save habit
Steady’s button component set: every Type and State combination for one size

Component properties: switches without multiplication

Variant properties multiply. Three types × three states × two sizes is 18 variants. Add a two-value Icon variant property and it becomes 36, every one of which has to be built and kept in sync. This is called variant explosion, and it is the most common way design systems become unmaintainable.

Component properties handle the differences that do not need a separately designed version:

  • Boolean: shows or hides a layer. Show icon true or false. One layer, no new variants.
  • Text: exposes a text layer’s content. Label = “Save habit”. People edit it from the properties panel without hunting for the layer.
  • Instance swap: chooses which component fills a nested instance. Icon = Plus, Check or Bell. You can set preferred values, a short list of sensible icons, so nobody puts a trash can on the Save button.
  • Slot: at the time of writing, a newer property type that marks an area where instances can hold their own content, such as the body of a bottom sheet, while everything around it stays linked.

You add these on the main component: select the layer, then use the property option next to its visibility (boolean), its text content (text) or its nested instance (instance swap) in the right sidebar, or create one from the properties section and connect it to a layer.

Build order matters

Add text, boolean and instance swap properties to the first component before you add more variants. New variants created from it inherit those property connections. If you build 18 variants first, you will connect the label layer 18 times.

The Habit row gets the same treatment:

Text
Habit row (component set)
  State      variant        To do | Done | Missed
  Name       text           "Read 20 pages"
  Show streak boolean       true
  Icon       instance swap  Habit icon/Book  (preferred: Book, Water, Run, Sleep)

Three variants instead of dozens, because Done and Missed restyle several layers (check fill, name color, a strikethrough) while everything else is a property.

When a component nests other components, people would normally have to dig into layers to reach the inner ones’ properties. At the time of writing, a component author can expose nested instances, so the Check button’s own properties appear alongside the Habit row’s in the panel.

Your kit now has a handful of flexible components. Their colors and numbers, though, are still typed in by hand. Next you move those values into styles and variables.

Key takeaways

  • Variants group versions of a component in one component set, described by properties such as Type and State.
  • Use variants for differences that restyle several layers at once, such as states, types and sizes.
  • Use a boolean property for show or hide, a text property for editable labels and an instance swap property for choosing a nested component.
  • Every variant property multiplies the variant count, while boolean, text and instance swap properties do not.
  • Slots, at the time of writing, mark areas of a component where instances can hold free content without detaching.

Further reading

Check your understanding

4 questions

Question 1 of 4

Steady’s button has Type (Primary, Secondary, Ghost), State (Default, Pressed, Disabled) and Size (Medium, Small) as variant properties. A teammate wants “with icon” and “without icon” as another variant property. How many variants would that create, and what is the alternative?

Question 2 of 4

Which property type fits the habit name in the Habit row component?

Question 3 of 4

When should a difference be a variant rather than a boolean?

Question 4 of 4

The New habit sheet component must hold different content in different flows (a form, a confirmation, an icon grid). What fits best at the time of writing?

Practice

Put in order

Build the button component in the right order

You are building Steady’s button: Type and State as variant properties, plus a text property for the label, a boolean to show the icon and an instance swap for which icon. Put the steps in the order that avoids redoing work.

Use the arrow buttons to reorder.

  1. 1Build the default primary button as an auto layout frame with named Icon and Label layers.
  2. 2Add a text property for Label, a boolean for Show icon and an instance swap for Icon.
  3. 3Restyle each variant: secondary and ghost colors, pressed and disabled states.
  4. 4Place an instance and switch every property, with a long label and the icon off, to check nothing breaks.
  5. 5Add variants and name the variant properties Type and State with their values.
  6. 6Turn the frame into a main component.