Variants, slots and swaps
This page helps you make one component that has many states. It also explains slots and swaps.
Example: a button has the variants "default", "hover" and "pressed". Together they are a variant set.
How to make a variant set
- Select the main component.
- In the right panel, find the Variants section.
- Click Make variant set. This component is now the first variant of a set.
- Click Add variant.
- Change the new variant so it looks different, for example for the hover state.
Each variant has property values, such as state=hover or size=lg.
If two variants have the same values, Brsh warns you. Change one of them so they can be told apart.
How to change the set name or properties
- Select a variant component.
- Open Set name, property names and values, add a property, remove from set.
- Edit the set name, a property name or a value.
- Click Add property to add a new property.
How to switch an instance to another variant
- Select the instance.
- In the right panel, find the section named Variant with the set name.
- Choose a value for each property.
The instance changes to the matching variant. Your overrides stay. They follow the layers by name.
Slots and swaps
A slot is an empty place in a component. An instance can put its own layers there.
A swap puts a different layer in place of one layer in an instance.
Today, the right panel has no slot or swap control. You use them in two ways:
- Ask an agent to do it.
- Write them in the design file. The file format guide shows how.