Build a button component
Make a button once, with a label you can change, an icon you can switch off, and sizes and states, then use it across your files and update them all from one place. About ten minutes.
Start in a new file: in your library, click New at the top right and choose New file. If you made a design system in Put your brand in a design system, choose it in Assets first, so the button uses your colours.
1. Draw the button
- On the toolbar at the bottom of the board, click Text (the T). Click the board and type Button. Press Esc to stop typing; the text stays selected.
- Right-click the text and choose Add flex (or press ⇧A). The text is wrapped in a frame that hugs it and lays it out.
- With the new frame selected, set its padding in the right panel under Layout: 16 across and 10 down.
- Under Appearance, set the Corner radius to 8. Under Fill, choose a colour, or your primary colour with Apply variable.
- Click the text inside the button to select it, and give it a white fill, or your text-on-primary colour.
- For the icon, click the small corner on the toolbar's shapes button (the square, after the folder) and choose Ellipse. Drag a small circle beside the button, holding ⇧ to keep it round, about 16 × 16. Drag it into the button, before the text: the frame makes room for it.
- In the left panel's Layers tab, double-click the frame's name and call it Button; call the circle Icon.
2. Make it a component
Right-click the Button frame on the board and choose Create component (or press ⌥⌘K). Its name turns purple: this is now the main component, and every copy of it follows what you change here.
3. Add a label and an icon switch
Properties are what someone can change on each copy without breaking it away from the main one.
- Select the text inside the main component. Beside the Text heading in the right panel, click the purple diamond (Apply text property) and choose Create property.
- Select the Icon circle. Beside Appearance, click the diamond (Apply boolean property) and choose Create property.
- Select the main component. Under Properties, double-click each new property to rename it: Label and Show icon.
4. Add Size and State
- Right-click the main component and choose Add variant. It becomes a set of two variants, one under the other, and Properties on the set shows Property 1 with the values Default and Variant2.
- Select the set by clicking its name above it, and double-click Property 1. Rename it Size.
- Select the first variant. Under Current variant, change Size to Medium. Select the second and change it to Small, then give it less padding and a smaller text size.
- Select the set, click + beside Properties (Create property) and choose Variant. Rename the new property State; every variant starts as Default.
- Select the Medium variant and choose Add variant again. In Current variant, set the copy to Size Medium, State Hover, and make its fill a little darker. Do the same from the Small one.
You now have four: Medium and Small, each Default and Hover. If two end up with the same values, the set's Properties warns you: Give each its own.
5. Place copies and change them
- At the top of the left panel, click the Assets tab. Your button is under Created in this file. Drag it onto the board, or into a frame. Do it twice.
- Select a copy. The right panel lists its properties: choose a Size and State, type a new Label such as Sign up, and turn Show icon off on the other.
- Now select the main component and change its corner radius. Every copy follows, and keeps its own label and choices.
To edit a copy freely, right-click it and choose Detach instance: it becomes plain layers and stops following. Reset instance undoes your changes to a copy instead.
6. Publish it as a library
- In Assets, click the Local variables button beside the design system box. A panel opens under the board.
- Choose its Library tab and Publish as a library. It says Published as a library, with a version number.
7. Use it in another file
- Open another file in the same workspace. In Assets, your first file now has its own group: drag the button in from there.
- Back in the first file, change the main component, say its fill. In the Library tab choose Publish changes.
- In the other file, Assets says 1 library update. Choose Review, then Update. The copies there change, and Undo is offered if you want them back.
Next
- Components: instance swaps, nested instances, and how overrides are kept.
- Layout: flex, padding, gaps and sizing.
- Build with components, so your agent builds repeated parts this way too.