Variant properties (boolean, enum) in Figma - Real Business Scenario
| Filter | Type | Options |
|---|---|---|
| Show Region | Boolean | True / False |
| Time Period | Enum | Monthly / Quarterly / Yearly |
Design the panel with a checkbox labeled 'Show Region' and a dropdown labeled 'Time Period' with options 'Monthly', 'Quarterly', 'Yearly'.In the Variants panel, add 'Show Region' as boolean and 'Time Period' as enum with three options.Generate 6 variants: Show Region true with Monthly, Quarterly, Yearly; Show Region false with Monthly, Quarterly, Yearly.For each variant, set checkbox state and dropdown label accordingly.Link prototype interactions to switch between variants by toggling 'Show Region' and selecting 'Time Period'.Filter Panel Component Variants +-----------------------------+ | [x] Show Region | | Time Period: Monthly ▼ | +-----------------------------+ Variants: 1) Show Region: True, Time Period: Monthly 2) Show Region: True, Time Period: Quarterly 3) Show Region: True, Time Period: Yearly 4) Show Region: False, Time Period: Monthly 5) Show Region: False, Time Period: Quarterly 6) Show Region: False, Time Period: Yearly
Add a third variant property 'Sort Order' as an enum with values 'Ascending' and 'Descending' to the filter panel component and create all new variants accordingly.
Practice
What is the main purpose of variant properties in Figma components?
Solution
Step 1: Understand variant properties
Variant properties allow you to manage multiple versions of a component in one place.Step 2: Identify the benefit
This avoids creating many duplicate components and keeps design organized.Final Answer:
To create different versions of a component without duplicating it -> Option AQuick Check:
Variant properties = different versions without duplicates [OK]
- Thinking variants add animations
- Confusing variants with export options
- Believing variants change colors automatically
Which of the following is the correct way to define a boolean variant property in Figma?
{
"property": "isActive",
"type": "boolean",
"values": [true, false]
}Solution
Step 1: Check property type
The type is set to "boolean", which is correct for true/false values.Step 2: Check values array
The values array contains true and false, which are the two valid boolean options.Final Answer:
Correct syntax for a boolean variant property -> Option BQuick Check:
Boolean variant = true/false values [OK]
- Using strings instead of boolean true/false
- Adding more than two values for boolean
- Using numbers as property names
Given this enum variant property definition:
{
"property": "size",
"type": "enum",
"values": ["small", "medium", "large"]
}What will be the selected variant if the property size is set to "medium"?
Solution
Step 1: Understand enum variant property
Enum properties let you pick one option from a list of named values.Step 2: Check the selected value
Setting size to "medium" selects the variant with that exact value.Final Answer:
The component variant with size set to "medium" will be shown -> Option AQuick Check:
Enum property selects one named option [OK]
- Confusing enum with boolean type
- Expecting multiple variants to show
- Assuming default is always first value
Identify the error in this variant property definition:
{
"property": "visible",
"type": "boolean",
"values": ["true", "false"]
}Solution
Step 1: Check boolean values
Boolean variant values must be the boolean literals true and false, not strings.Step 2: Identify the mistake
Using "true" and "false" as strings is incorrect syntax for boolean type.Final Answer:
Boolean values should be true and false without quotes -> Option CQuick Check:
Boolean values = true/false literals [OK]
- Using strings instead of boolean literals
- Changing property name unnecessarily
- Confusing boolean with enum type
You want to create a Figma component with a variant property theme that can be either "light" or "dark", and another boolean variant property disabled. How should you define these variant properties?
Solution
Step 1: Define enum property for theme
The theme property has multiple named options, so it should be an enum with values "light" and "dark".Step 2: Define boolean property for disabled
The disabled property is true or false, so it should be boolean with values true and false.Final Answer:
{ "property": "theme", "type": "enum", "values": ["light", "dark"] }, { "property": "disabled", "type": "boolean", "values": [true, false] } -> Option DQuick Check:
Enum for multiple options, boolean for true/false [OK]
- Mixing enum and boolean types incorrectly
- Using strings for boolean values
- Assigning wrong values to properties
Ready to prove it?
Pass the test and this pattern moves unknown
