- Product: Figma Design
- Topics: Auto layout, components, variants, prototyping
- Difficulty: Intermediate
- Length: 20 minutes
In this project, we’re going to design a reusable button component that changes as you interact with it. To do this, we’ll build a button component set using variants, then configure prototyping connections to add interactivity.
Create the save icon
To start, we’ll create a simple save icon that we’ll add to our button later.
- Use the Frame tool to add a 24 X 24 frame to the canvas.
- Double-click on the frame name and rename it to
icon. - Click the minus in the Fill section to remove the frame’s fill.
- Use the Rectangle tool to add a 12 X 18 rectangle to the center of the frame.
- Press Shift X to swap the rectangle’s fill and stroke.
- Use the Stroke section of the right sidebar to configure the stroke to the following:
-
Fill:
#000000 -
Position:
Inside -
Weight:
2
-
Fill:
- Change the Corner radius to
1. - Select the rectangle and press Enter to open vector edit mode.
- Hover over the bottom of the rectangle and click to add a new vector point.
- Select the point and change the Y-position value to
17. - Press Enter again to close vector edit mode.
- Select the frame and click Create component in the right sidebar or use the keyboard shortcut:
- Mac: Option Command K
- Windows: Ctrl Alt K
Create the icon component set
Nice work! Next, we’ll create a filled variant of our save icon that will display when the button is pressed.
Select the component you just created and click Create variant in the right sidebar.
When you add your first variant, Figma will make an identical component with the same properties applied and add both to a component set, identified by a dashed purple border. Because our original component was named icon, the component set is automatically named icon. If you take a look at the right sidebar, you’ll notice a new component property called Property 1 is available, with default and Variant2 as available values. Let’s update this property and configure the rest of our icon component set.
- Select the original component at the top of the component set.
- In the Current variant section of the right sidebar, click on the property name (currently called Property 1) and change it to
Has fill. - Click on the property value (currently called default) and change it to
false. - Next, click on the second variant in the component set and change its
Has fillproperty value totrue. - Select the vector inside the Has fill=true variant, click the plus in the Fill section and change its fill to
#000000.
Your icon component set should look similar to the following:
Tip: You can also find pre-made icon sets on the Figma Community.
Create the button main component
Next, we’ll create the button main component.
- Select the Text tool, click on the canvas, and type
Save. - Double-click on the layer name and rename it to
label. - Use the Typography section of the right sidebar to change the font family to
Outfitand the font size to16. - Select the text layer and press Shift A to apply auto layout.
- Set the Horizontal resizing and the Vertical resizing to
Hug Contents. - Click the plus in the Fill section of the right sidebar and change the fill to
#DEB0FB. - Click the plus in the Stroke section of the right sidebar and configure the stroke to the following:
-
Fill:
#000000 -
Position:
Inside -
Weight:
1
-
Fill:
- Change the Corner radius to
1000px. - Click the plus in the Effects section of the right sidebar, choose Drop shadow from the menu, and configure the effect to the following:
-
X-position:
-2 -
Y-position:
4 -
Blur:
0 -
Color:
#000000at100%opacity
-
X-position:
- In the Auto layout section of the right sidebar, change the Horizontal padding to
32and the Vertical padding to24. - Select the frame and click Create component in the right sidebar or use the keyboard shortcut:
- Mac: Option Command K
- Windows: Ctrl Alt K
- Double-click on the frame name and rename it to
button/default/unsaved.
Before moving on, check to make sure your button component looks similar to the following:
Add an icon instance to the button
We’re now ready to add an instance of the save icon to our button component.
- Select the Has fill=false icon variant in the component set and hold the shortcut while dragging your cursor to create an instance:
- Mac: Option
- Windows: Alt
- Drag the instance into the button frame, to the left of the label. Because the frame has auto layout applied, it automatically adjusts to fit the icon.
- In the Auto layout section, set the Gap to
12.
Apply boolean properties to the icon and label
The button is looking great! However, you may not always need both an icon and a label when reusing this component across different designs. For example, you may want to use an icon-only button when screen space is limited or when the action is universally recognized, such as a Like button. Instead of creating multiple button variants, we can add a boolean property to the icon and label that will allow us to toggle their visibility on or off as needed.
To apply a boolean property:
- Select the
labellayer inside the button component. - In the Appearance section of the right sidebar, click Apply variable/property.
- Click the plus to add a new property and configure it to the following:
-
Create:
Property -
Name:
Show label -
Value:
True
-
Create:
- Click Create property.
- Next, click the icon layer inside the button component and repeat the process, configuring the new property to the following:
-
Create:
Property -
Name:
Show icon -
Value:
True
-
Create:
- Click Create property.
When you select the button component, you’ll now see the new boolean properties in the Properties section of the right sidebar.
You can test out these properties by creating an instance of your button component and using the toggles to show or hide the icon and label.
Create the button variants
Now that we have our main button component, we’ll use it to create variants and build our component set.
Configure the unsaved variants
First, we’ll add our unsaved variants:
- Select the button component and click Add variant in the right sidebar.
- Click the purple plus below the new variant to add a third variant. You should have three buttons in total.
Next, we’ll configure the default, hover, and pressed states:
- Select the original variant at the top of the component set. In the Current variant section of the right sidebar, you’ll see that this variant has two properties: Property 1 with a value of
defaultand Property 2 with a value ofunsaved. - Click on Property 1 and rename it to
state, then click on Property 2 and rename it tostatus. - Select the middle button variant. Next to the state property, type
hoverin the value field to add a new value. Then use the Fill section to change the variant’s fill to#EFD9FF. - Select the third variant. Next to the state property, type
pressedin the value field. Then use the Fill section to change the variant’s fill to#C48FE5.
Before moving on, check to make sure your component set looks similar to the following:
Configure the saved variants
Our component set is coming together! Next, we’ll add the saved variants.
- Click the purple plus at the bottom of your component set to add another variant.
- With the new variant selected, type
savedin the status property field. - Select the
iconframe inside the button and switch the Has fill property totrue. - Double-click on the text layer inside the new variant and type
Saved.
Now we’ll add two more variants:
- Select the new saved variant and add two more variants.
- Select the middle variant and change the state property value to
hoverand the fill to#EFD9FF. - Select the third variant and change the state property value to
pressedand the fill to#C48FE5.
Before moving on, check to make sure your component set looks similar to the following:
Add prototype connections to your button
We’ll finish our button by adding prototype connections to make our component interactive. If you’re new to prototyping, check out the glossary in our Guide to prototyping to learn more about the terms used in this section.
Planning out prototype connections
Before adding prototype connections, it’s important to plan out what you want the interaction experience to be.
When recreating common UI elements (like buttons), look at how they behave in real products or design systems. Pay attention to how they look and respond to interactions, and try matching those actions with corresponding prototype triggers in Figma, such as while hovering, on click, mouse enter, etc.
For more complex components, consider creating a flowchart to help breakdown the interaction into more digestible steps. Figma integrates with AI tools like Claude and ChatGPT, making it easy to turn prompts into structured diagrams in FigJam.
For this button, our interactions will look like this:
- When a cursor is hovering over the button, we want our variant to change from the
defaultstate to thehoverstate - When a cursor presses down on the button, we want our variant to change to the
pressedstate - If the cursor leaves the button surface while pressing down, we want the variant to remain in the
defaultstate - When the unsaved button is pressed, we want the variant to change to
saved - When the saved button is pressed, we want the variant to change to
unsaved
Add the hover trigger
- Switch to the Prototype tab in the right sidebar.
- Hover over the
default, unsavedvariant. Then click and drag the blue plus to thehover, unsavedvariant. - Configure the interaction settings to the following:
-
Trigger:
While hovering -
Action:
Change to -
Animation:
Smart animate -
Transition:
Ease in and out -
Duration:
150 ms
-
Trigger:
- Apply an identical prototype connection between the
default, savedandhover, savedvariants.
Your first two connections should look like this:
Why set the animation duration to 150 ms?
Animations bring joy to digital interactions and can be used to communicate intended behavior. When animating your designs, make sure that it enhances the user experience without delaying people from reaching their goal. For web-specific content, it’s common practice to have animations to land in the 150-300 ms range. Animations in this range will allow users to notice the interaction but will not prevent them from moving forward in a timely manner.
Add the mouse down trigger
- Select the
hover, unsavedvariant, then click and drag the blue plus to thepressed, unsavedvariant. - Configure the interaction settings to the following:
-
Trigger:
Mouse down -
Action:
Change to -
Animation:
Smart animate -
Transition:
Ease in and out -
Duration:
150 ms
-
Trigger:
- Apply an identical prototype connection between the
hover, savedandpressed, savedvariants.
Your connections should look like this:
Add the mouse leave trigger
- Select the
pressed,unsavedvariant, then click and drag the blue plus to thedefault, unsavedvariant. - Configure the interaction settings to the following:
-
Trigger:
Mouse leave -
Action:
Change to -
Animation:
Smart animate -
Transition:
Ease in and out -
Duration:
150 ms
-
Trigger:
- Apply an identical prototype connection between the
pressed, savedanddefault, savedvariants.
Your connections should look like this:
Add the mouse up trigger
We need to add two final connections so that the unsaved button switches to the saved button when pressed, and vice versa.
- Select the
unsaved, pressedvariant, then click and drag the blue plus to thedefault, savedvariant. - Configure the interaction settings to the following:
-
Trigger:
Mouse up -
Action:
Change to -
Animation:
Smart animate -
Transition:
Ease in and out -
Duration:
150 ms
-
Trigger:
- Apply an identical prototype connection between the
pressed, savedanddefault, unsavedvariants.
Your final connections should look like this:
Test your button
Awesome job! Our component set is complete and it’s time to see your button in action!
- Use the Frame tool to add a frame large enough to fit your button to the canvas.
- Navigate to the Assets tab in the left sidebar and drag an instance of your button into the frame.
- With the new frame selected, open the Prototype view dropdown in the right sidebar and select Preview or press Shift Space to launch the inline preview.
- Use your cursor to interact with your button.
What’s next?
Congratulations! You just created an interactive button using a component set and prototyping. If you’re looking for another challenge, check out our Create a responsive card project or the Figma Design for beginners course for more hands-on learning opportunities.
Check your knowledge