Guide
Create a Responsive Button in Figma Using Auto Layout and Component Variants
Learn how to build a Figma button that resizes its width based on label text using Auto Layout and component variants.
Published by Tasadduq Burney
09 Oct 2025, 09:52 UTC
2 min132.8K views0

Desired outcome
Create a button component that automatically adjusts its width to fit the label text while keeping padding, corner radius, and state styles consistent.
Prerequisites
- A Figma file with edit access (desktop or web app, version ≥ 2021).
- Basic familiarity with frames, text layers, the Assets panel, and Auto Layout.
Procedure
- Select the Text tool, type a label (e.g.,
OK) and place it on the canvas. - With the text layer selected, press Shift+A to create a frame around it. In the right‑hand panel set:
- Horizontal padding:
12px - Vertical padding:
8px - Corner radius:
4px - Fill: choose a default button colour (e.g.,
#1E90FF).
- Horizontal padding:
- With the frame selected, click the Auto Layout button in the properties panel. Set:
- Horizontal resizing: Hug contents
- Vertical resizing: Fixed
- Spacing between items:
0(only one child).
- Convert the frame to a component: right‑click → Create component (or Ctrl+Alt+K/Cmd+Option+K).
- In the Assets panel, click the + next to the component name to add variants. Create four variants named Default, Hover, Pressed, and Disabled.
- Select each variant and adjust its appearance:
- Hover: change fill to a slightly darker shade (e.g.,
#1C86EE) or add a subtle shadow. - Pressed: reduce opacity or shift fill further (e.g.,
#1A75DD). - Disabled: lower opacity to ~40% and change fill to a neutral grey (e.g.,
#CCCCCC).
- Hover: change fill to a slightly darker shade (e.g.,
- Optionally, add text style overrides per variant if you want the label colour to change.
Expected checks
- Select the component instance, double‑click the label, and change the text to a short string (
OK) and then to a longer string (Submit Form). Verify that the button width expands or contracts while the horizontal and vertical padding stay at the values set in step 2. - Switch to the Prototype tab, connect the Default variant to the Hover variant with an While hovering interaction, and the Hover to Pressed with While pressing. Preview to confirm the correct variant appears and the button resizes smoothly as the label changes.
- Open the Inspect panel for an instance; the width value should change only when the label length changes, confirming that Auto Layout is driving the size.
Recovery options
If the button does not resize as expected:
- Select the frame, reset Auto Layout constraints by toggling the resizing settings back to Hug contents (horizontal) and Fixed (vertical).
- Re‑apply the padding values from step 2.
- Detach the instance (Ctrl+Shift+D/Cmd+Shift+D) and repeat the procedure to create a fresh component.
- Use Ctrl+Z/Cmd+Z to undo recent changes, or open File → Version history to restore a prior version.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.