You will build: Brand tokens, a button class with a secondary combo class, and a button component placed as instances across a page
Read first: Build a landing page
In this tutorial you set up the building blocks that keep a site consistent: tokens for your brand colours, fonts and spacing, classes that reuse a look, and a component that reuses a structure. At the end, changing one token or one component updates the whole site. Start from any page with a few buttons, for example the page from the Build a landing page tutorial.
Set up tokens
Open the Tokens tab
The inspector on the right has three tabs: Design, Interactions and Tokens. Open Tokens. It has three sections: Colors, Spacing and Fonts. Tokens belong to the site, so every page shares them.
Add your brand colours
In Colors, press + (Add color token). A token named
colorappears. Rename it tobrandand pick your main colour in the colour field next to the name. Add two more:inkfor text andsurfacefor backgrounds.Add a spacing scale
In Spacing, press + (Add spacing token) and add a few steps, for example
smat 8,mdat 16 andlgat 32.Add your fonts
In Fonts, open Add font… and pick a Google font for headings, for example
Google · Inter. For Google fonts, the token shows the weights you can turn on or off. Add a second font for body text if you want one.
The Tokens tab lists three colours, three spacing steps and at least one font.
Use tokens in styles
Apply a colour token
Go back to Design and select the page's button. In Fill, click the colour swatch and pick
brandfrom the token palette. The field now shows the token name instead of a hex value.Apply a spacing token
In Layout → Padding, press the variable icon (Use a spacing token) and pick
md. Padding, Margin and Gap all accept spacing tokens.Apply a font token
Select a heading. In Typography → Font, the font tokens are listed first. Pick the one you added.
Change a token
Open Tokens and change the colour of
brand. Every element that uses it updates at once. To break the link on one element, press Detach token next to the token name; the element keeps the current value.
Build a button class
Add a class
Select the button. In the class bar at the top of the Design tab, type
btnin Add class… and press ↵. A.btnchip appears.Style the class, not the layer
Below the chips, set Style to Class .btn (or click the chip). Now set the fill, the padding, a Radius in Border and the font. These styles live on the class, so every element with
.btngets them.Add a hover state
With the class still targeted, pick Hover in the state bar above the sections and change the fill a little. Pick Default to go back.
Reuse the class
Select another button, type
btnin Add class… and press ↵. The class name is suggested as you type. The button takes the whole look at once.
Add a combo class
Create the combo
Select the second button. Type
is-secondaryin Add class… and press ⇧↵. Shift+Enter creates a combo class on top of the last class, so.is-secondaryonly applies together with.btn.Style the difference
Set Style to Class .is-secondary. Change only what differs: a transparent fill, a border in
brandandbrandtext. Everything else still comes from.btn.See it propagate
Change the radius on
.btn. Both buttons follow, and the secondary one keeps its own fill and border.
The page has a primary and a secondary button. Both share the base .btn style, and the secondary one adds its own look.
Make a button component
Create the component
Select the primary button and press ⌘⌥K, or right-click it and choose Create component. The button moves into a new component, and an instance takes its place on the page.
Name it
Open the Components tab in the left sidebar. Right-click the new component, choose Rename and call it
Button.Place instances
Drag
Buttonfrom the Components tab onto the page, or press the + on its row (Insert Button). Place two or three instances.Override the text
Select one instance and double-click its text. Type a new label, for example
Book a call. The new text is an override: it applies to this instance only.Read and reset overrides
With the instance selected, the Instance section lists its overrides. Press the reset arrow next to an override to go back to the component's value.
Edit the component
Press Edit component in the Instance section and change the button, for example its padding. Every instance updates, and overridden text stays as it is.
Your site has brand tokens, a .btn class with a secondary combo, and a Button component placed several times with its own text on each instance.
What you learned
- Tokens hold your brand colours, spacing and fonts in one place; changing a token updates every element that uses it.
- Classes share a look, combo classes add a variation on top of a base class, and states such as Hover work on classes too.
- Components share a structure; each instance can override its text and still receive every other change.
Keep going with the next tutorials, or read the guides behind this one: