Things that belong together sit close; separate groups sit further apart. People see the groups before they read a word, so spacing groups the content before any heading does.
Every space is a spacing token. Pick the step by how closely two things belong together.
The scale
14 steps on an 8 px base. Each step has its own job, shown beside it.
The token number is a percentage of 8 px: space.100 is 8 px, space.200 is 16 px, and space.075 is 6 px. The steps grow further apart as they get larger, because a 4 px change is clear between small gaps and invisible between large ones.
space.0--bh-space-00 px0Joined items, such as the buttons of a segmented group.space.025--bh-space-0252 px0.125remA badge on an icon, a status dot beside text. Never between controls or as padding.space.050--bh-space-0504 px0.25remBetween an icon and 14 px text; between a title and its description; above and below the text of a tooltip and of a compact table cell.space.075--bh-space-0756 px0.375remInside components only: above and below the label of a 32 px control, and the sides of a tooltip. Never for layout, sections or card padding.space.100--bh-space-1008 px0.5remBetween an icon and 16 px text; between buttons; between a label and its field; side padding of 24 px controls; above and below the text of a table cell.space.150--bh-space-15012 px0.75remSide padding of 32 px controls, such as text fields and buttons, and of table cells.space.200--bh-space-20016 px1remBetween related items: fields, list items, cards. Page margin and grid gutter below 768 px.space.250--bh-space-25020 px1.25remBetween a section heading and its content. The edge of the logo and the side navigation icons.space.300--bh-space-30024 px1.5remInside cards, panels and dialogs. Between tabs. Page margin and grid gutter from 768 px.space.400--bh-space-40032 px2remBetween groups, such as form sections. Page margin from 1440 px.space.500--bh-space-50040 px2.5remAround empty states.space.600--bh-space-60048 px3remBetween page sections.space.800--bh-space-80064 px4remBetween the major sections of a long page. The width of the collapsed side navigation.space.1000--bh-space-100080 px5remTop and bottom of sign-in and onboarding pages. Use rarely.
When two things could take either of two steps, ask how much they belong together. More related means smaller.
Padding and gap
gap, never as margins on the children.- Padding is the space inside an element. Set it on the element.
- Gap is the space between elements. Set it on their parent with
gap, in flex or grid layout. - Avoid margins between siblings. They add up where two meet and leave space after the last item;
gapdoes neither. - Measure padding from the outer edge, border included. A 32 px input with a 1 px border has 11 px of padding inside the border, so its text sits 12 px from the edge.
The 8 px base
From 8 px up, every space is a multiple of 4 px. Below 8 px, the scale also has two 2 px steps: 2 and 6 px.
| Range | Steps | Use |
|---|---|---|
| Compact, below 8 px | 2, 4, 6 | Inside components only |
| From 8 px | 8, 12, 16, 20, 24, 32, 40, 48, 64, 80 | Components, layout and page sections |
- Text line heights are multiples of 4 px too (see Typography). Text, controls and spaces line up.
- Use
space.025(2 px) only to nudge a small thing into place: a badge on an icon, a status dot beside text. Never use it between controls or as padding. - Use
space.075(6 px) only inside components, in two places: above and below the label of a 32 px control, where (32 − 20) ÷ 2 = 6, and the sides of a tooltip. Never use it for layout, sections or card padding, or between an icon and text: that gap is 4 px next to 14 px text and 8 px next to 16 px text and larger. - Borders and focus rings are not spacing. Keep them out of your sums except for padding, as above.
No negative space
There are no negative spacing tokens.
- When two things overlap, such as a stack of avatars, the component sets the overlap.
- Do not use a negative margin to pull an element into line. Fix the spacing around it.
Do and don’t
Put a label closer to its own field than to anything else, and groups further apart than fields.
The same space everywhere. Readers cannot tell which label belongs to which field.
gap: var(--bh-space-200);
padding: var(--bh-space-300);Use a spacing token for every padding, gap and margin.
gap: 18px;
padding: 13px 22px;Pixel values off the scale. Nothing lines up, and each screen drifts a little further.
Use 2 px only to nudge a badge or a dot. Buttons stay 8 px apart.
Controls 2 px apart. They read as one control and are easy to tap by mistake.
Vietnamese text
Vietnamese text needs taller lines for its accents. The text styles add that height on their own (see Typography), so spacing does not change: use the same tokens in both languages.
Vietnamese labels are often longer than English ones. Let them wrap, or give the container room. Do not take space away to make a label fit.
Tokens
Most spacing comes from a token named after the kind of element, not from the scale. A family token points to a step of the scale, so every element of that kind changes together. Take a step from the scale only when no family covers the case.
- Controls:
space.control.x(and.small,.large) beside the label,space.control.gapbetween icon and label. - Items:
space.item.xin menus, lists and side navigation. - Overlays:
space.overlayinside menus and popovers,space.overlay.offsetfrom the element that opened them. - Cards and dialogs:
space.card,space.modalandspace.modal.gap. - Tables:
space.table.cell.xandspace.table.cell.y. - Columns:
space.stackbetween fields, list items and cards;space.stack.groupbetween groups.
| Token | Value | Description |
|---|---|---|
--bh-space-control-x | {space.150}0.75rem | Side padding of 32 px controls: buttons, text fields, selects. |
--bh-space-control-x-small | {space.100}0.5rem | Side padding of 24 px controls. |
--bh-space-control-x-large | {space.200}1rem | Side padding of 40 px controls on sign-in and onboarding pages. |
--bh-space-control-gap | {space.050}0.25rem | Between the icon and the label inside a control. |
--bh-space-item-x | {space.150}0.75rem | Side padding of items in menus, lists and side navigation. |
--bh-space-overlay | {space.050}0.25rem | Inside menus, selects and popovers that hold a list, around their items. Nests the corners: radius.overlay = radius.item + space.overlay. |
--bh-space-overlay-offset | {space.050}0.25rem | Between a menu, popover or tooltip and the element that opened it. |
--bh-space-overlay-content | {space.200}1rem | 16 px. Inside popovers and hover cards that hold content rather than a list. Lists keep space.overlay. |
--bh-space-card | {space.300}1.5rem | Inside cards and panels. |
--bh-space-modal | {space.300}1.5rem | Inside dialogs and drawers. |
--bh-space-modal-gap | {space.200}1rem | Between the title, body and actions of a dialog or drawer. |
--bh-space-table-cell-x | {space.150}0.75rem | Side padding of table cells. |
--bh-space-table-cell-y | {space.100}0.5rem | Top and bottom padding of table cells. |
--bh-space-stack | {space.200}1rem | Between related items in a column: form fields, list items, cards. |
--bh-space-stack-group | {space.400}2rem | Between groups in a column, such as form sections. |
Related
- App frame: the spacing that lines up the header, side navigation and page header.
- Grid: columns, gutters and page margins at each breakpoint.
- Size and density: control heights.