0
0
Figmabi_tool~10 mins

Variant matrix organization in Figma - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a variant with a specific property value.

Figma
const button = figma.createComponent();
button.variantProperties = { 'Size': [1] };
Drag options to blanks, or click blank then click option'
A'Large'
B'Blue'
C'Disabled'
D'Active'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a property value that doesn't match the variant property name.
Forgetting to use quotes around the string value.
2fill in blank
medium

Complete the code to access the variant property named 'Color'.

Figma
const variantColor = component.variantProperties[[1]];
Drag options to blanks, or click blank then click option'
A'Color'
B'State'
C'Size'
D'Shape'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong property name string.
Not using quotes around the property name.
3fill in blank
hard

Fix the error in setting multiple variant properties at once.

Figma
component.variantProperties = [1];
Drag options to blanks, or click blank then click option'
A[ 'Size', 'Large', 'Color', 'Blue' ]
B{ Size: Large, Color: Blue }
C{ 'Size': 'Large', 'Color': 'Blue' }
D['Size' => 'Large', 'Color' => 'Blue']
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting keys or values.
Using array syntax instead of object syntax.
4fill in blank
hard

Fill both blanks to create a variant matrix with two properties: Size and Color.

Figma
const variantMatrix = {
  [1]: ['Small', 'Medium', 'Large'],
  [2]: ['Red', 'Green', 'Blue']
};
Drag options to blanks, or click blank then click option'
A'Size'
B'Color'
C'State'
D'Shape'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the property names.
Using incorrect property names not defined in the variant.
5fill in blank
hard

Fill all three blanks to set variant properties and retrieve a variant node by matching properties.

Figma
component.variantProperties = { [1]: 'Medium', [2]: 'Green' };
const variantNode = component.findVariant({ [1]: 'Medium', [3]: 'Green' });
Drag options to blanks, or click blank then click option'
A'Size'
B'Color'
C'State'
D'Shape'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different property names between setting and finding variants.
Forgetting quotes around property names.