So you want Figma variant state switching / multiple selection? We got you covered (sort of)
Late last year Figma introduced Variants; a better way to organize components. Our studio welcomed it with open arms the moment the feature went out of beta status, and it has cleaned up our component libraries while also making design much easier.
But what about prototyping?
While variants may be the cleanest way to organize your components, they aren’t quite ready for the prototyping stage yet. As of now switching from one component state to another requires you to either make use of multiple artboards, or try using an overlay.
The big limitation with using an overlay is that you can only have a single one at a time. This makes it impossible to create a prototype for something like multiselect boxes without creating artboards for each and every permutation.
This is the (hacky) way
There is a way however to create a self-contained frame that allows for state switching using the Scroll To interaction.
Essentially what we’ll do to make it work is to create a frame that contains all the states you want to toggle to and on interaction scroll to the position in the frame that contains the desired next state. This technique is based on an animation tech from the late 70’s called Sprites.
Step 1: Create a frame that is exactly the width of 2x the width of your component, and stack your component states in there. Make sure to turn on Clip content and to enable the Left constraint. Switch to the prototyping tab for your frame and switch on Horizontal and Vertical Scrolling**
Step 2: Create 2 rectangles that align exactly on top of your components, inside of the same frame. These rectangles will serve as invisible buttons.
Step 3: Create an interaction for each button using the Scroll To interaction type. When you enable the Scroll To interaction, you can select a scroll target. For each of the two buttons select the opposite component state from the drop-down menu.
Step 4: Clean up. Once you have both buttons hooked up with interactions, we can make the component look the part. Select your fake buttons and give them 0% opacity to hide them. Make your outside frame exactly the width of the first component, clipping off the second state.
Step 5: You’re done! You can run your prototype and toggle your checkbox on and off now. Feel free to copy this component as many times as you like, they will all work independently.
**the hacky part
This method is far from perfect, because we’re using a scrollable container. The obvious pitfall is that the user could scroll the container manually and ruining the sense of a real prototype. The reason that we set our scrolling interaction to Horizontal and Vertical Scrolling, makes it less likely that the user accidentally scrolls horizontally, and at the same time preventing the scroll direction override that happens when we would only enable Horizontal Scrolling.
Happy prototyping!
Guus Baggermans is a Design Lead at argodesign. Specialising in digital user interfaces and prototyping rich experiences for Fortune 100 companies, multinational technology companies, and global financial institutions.