Spacing
One scale of spacing tokens on a 4px base. The name is the value: space-16 is 16px.
<div style="display: flex; gap: var(--space-8)"> <tk-button variant="primary">Save</tk-button> <tk-button>Cancel</tk-button> </div>
Using the scale
- Take every gap, padding, and margin from
space-*. All steps are multiples of 4px, except three fine steps described below. The full list is in thetoken table . - Set spacing on the parent:
gapandpaddingon the container, not margins on each child. - The most used steps are 8, 16, and 24. Use 32 to 96 between page sections.
space-0removes spacing.- Values don't change with screen size. To adapt a layout, pick a different step.
Distance shows relationship
Elements that sit close together read as one group. More space means a looser relationship. Space can separate groups without lines.
<div style="display: flex; flex-wrap: wrap; gap: var(--space-24)">
<div style="display: flex; gap: var(--space-8)">
<tk-button>Undo</tk-button>
<tk-button>Redo</tk-button>
</div>
<div style="display: flex; gap: var(--space-8)">
<tk-button>Cut</tk-button>
<tk-button>Copy</tk-button>
</div>
</div>| Step | Between |
|---|---|
space-8 |
items of one group, such as a label and its field |
space-16 |
separate items that sit side by side |
space-24 |
groups within one section |
space-32 |
sections of a page |
Use the same distance for the same kind of relationship, so the rhythm reads.
Fine steps
space-2, space-6, and space-10 are the only steps off the 4px base. They are for
padding inside small controls, where 4px steps are too coarse: space-6 pads a
space-10 pads a large field. Between blocks, use the
4px steps.
Accessibility
- Group with space, not only with lines or color. Clear grouping helps everyone, including people under cognitive load.
- Don't size tap targets from
space-*. A control's size comes from the component, not from the spacing around it.
Limits
- Spacing is in px. It grows with browser zoom, but not with the browser's default font-size setting.
Do / Don't
| ✅ Do | ❌ Don't |
|---|---|
Take values from the space-* scale |
Use values like 13px or 18px |
Set gap and padding on the container |
Put margins on each child |
Use space-8 inside a group and 24 or more between groups |
Use one spacing for everything |
| Repeat one distance for the same relationship | Mix 12 and 16 for no reason |
| Give sections room with 32 to 96 | Pack a page tightly to look compact |
| Change the step to adapt a layout | Compute fluid values between steps |
Related
Radius : nested corners depend on padding.Typography : line heights sit on the same 4px grid.Prose : spacing between blocks of authored text.
Sixteen steps, from 0 to 96px.
Scale
| Token | Variable | px | Typical use |
|---|---|---|---|
space-0 |
--space-0 |
0 | no spacing |
space-2 |
--space-2 |
2 | fine adjustment inside a control |
space-4 |
--space-4 |
4 | an icon and its text |
space-6 |
--space-6 |
6 | padding of a chip in a line of text, such as a key |
space-8 |
--space-8 |
8 | items of one group; padding of a medium field |
space-10 |
--space-10 |
10 | padding of a large field |
space-12 |
--space-12 |
12 | padding inside a component |
space-16 |
--space-16 |
16 | padding inside a component; separate items |
space-24 |
--space-24 |
24 | groups within a section |
space-32 |
--space-32 |
32 | sections |
space-40 |
--space-40 |
40 | large sections |
space-48 |
--space-48 |
48 | large sections |
space-56 |
--space-56 |
56 | generous section spacing |
space-64 |
--space-64 |
64 | generous section spacing |
space-80 |
--space-80 |
80 | around a hero |
space-96 |
--space-96 |
96 | the largest section spacing |
There are no tokens for breakpoints, column grids, or container widths.