Skip to content
tezvyn:
Menu

How do Figma variants influence component code structure?

Source: help.figma.comMediumHow cards are made

Tests design-to-code translation and component API modeling. Map variant properties to semantic props like size and type; handle interactive states internally via CSS. Prioritize property names over pixel values.

What's really being asked

This question tests whether you can bridge design tools and production code by treating Figma variants as a specification for a component contract rather than a visual mockup. Interviewers want to see that you understand which variant properties should become public props, which should be internal state, and how to avoid brittle hardcoding when translating design intent into a reusable UI component.

The full answer

First, map variant properties to a semantic prop interface. Properties like size, type, or icon position become explicit props with constrained values, while interactive states like hover, pressed, or focused should usually remain internal concerns handled by CSS or the component's own state logic. Second, inspect the full variant matrix to identify the complete set of combinations the designer intended; this prevents you from shipping a component that only handles the happy path shown in the mock. Third, prioritize the names and structure of variant properties over raw visual values. A property named size equals small tells you to map to a design token or spacing scale, whereas extracting width equals 32 pixels leads to fragile code. Fourth, flag missing or redundant variants. If the design shows state equals hover but not disabled, ask whether that omission is intentional or an oversight before you build.

The mistakes people make

Treating every variant permutation as a separate component, such as building ButtonHoverSmallPrimary and ButtonDefaultLargeSecondary, reveals a failure to abstract. Copying hex codes, font sizes, or pixel dimensions directly from the variant properties panel instead of mapping to tokens shows you do not understand design system architecture. Another red flag is exposing hover or active states as top-level props that consumers must manually toggle, which pushes interaction complexity to the parent and breaks accessibility.

What usually comes next

How would you handle a component with nested variants or boolean properties in Figma? What do you do when the variant matrix explodes combinatorially, for example with ten colors across five sizes and four states? How do you represent responsive behavior or auto layout constraints that are not explicitly captured as variant properties?

A concrete example

Imagine a button with variants for size equals small, medium, or large, type equals primary or secondary, and state equals default or hover. In code, you build a single Button component with props size and variant. The size prop maps to tokenized padding and font size scales. The variant prop maps to color and border tokens. The state equals hover variant is discarded as a prop and instead implemented with CSS hover pseudo-classes or an internal useHover hook. When the designer later adds a tertiary type, you only extend an enum rather than creating a new file.

Interview question

Which strategy best translates Figma size, type, and hover variants into a production-ready component?

  • a.Extract exact pixel values and hex codes from the variant panel and hardcode them as literal styles
  • b.Map size and type to semantic props backed by design tokens and handle hover internally via CSSCorrect
  • c.Create separate component files for each variant permutation to preserve the Figma structure exactly
  • d.Expose hover and pressed as top-level boolean props so parent components can toggle visual states explicitly
Why?

Mapping structural variants to semantic, token-backed props captures design intent without brittle hardcoding, while CSS pseudo-classes keep interaction logic encapsulated and accessible. Exposing hover as a manual prop is a tempting distractor that pushes state complexity to consumers and breaks expected interaction patterns.

Just read this? Test yourself on what you have been reading.

Read the original → help.figma.com

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on figma — each one lists the topics its interview covers.

See open roles