brsh

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 ​

  1. Select the main component.
  2. In the right panel, find the Variants section.
  3. Click Make variant set. This component is now the first variant of a set.
  4. Click Add variant.
  5. 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 ​

  1. Select a variant component.
  2. Open Set name, property names and values, add a property, remove from set.
  3. Edit the set name, a property name or a value.
  4. Click Add property to add a new property.

How to switch an instance to another variant ​

  1. Select the instance.
  2. In the right panel, find the section named Variant with the set name.
  3. 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.