Foundations
Spacing
19 spacing tokens, named for what they separate rather than how big they are. Pick the role and the size follows, so two components that mean the same thing end up the same distance apart. Spacing is the same in light and dark.
Tokens
Page layout
The side gutter and the gap between major sections. Both are fluid: they grow with the viewport between a minimum and a maximum.
| Token | Preview | Value |
|---|---|---|
--space-layout-margin | clamp(1.25rem, 4vw, 2rem) | |
--space-section-gap | clamp(3rem, 8vw, 5rem) | |
--space-layout-max-width | 1200px |
Gaps
Distance between things, from components in a section down to the tightest gap inside a small element.
| Token | Preview | Value |
|---|---|---|
--space-component-gap | 24px | |
--space-element-gap | 16px | |
--space-inline-gap | 8px | |
--space-label-gap | 12px | |
--space-tight-gap | 4px |
Padding
Space inside things. Control padding for buttons and inputs, prominent and compact for larger and smaller variants, container and dialog padding for boxes.
| Token | Preview | Value |
|---|---|---|
--space-control-padding-x | 16px | |
--space-control-padding-y | 12px | |
--space-prominent-padding-x | 24px | |
--space-prominent-padding-y | 16px | |
--space-compact-padding-x | 12px | |
--space-compact-padding-y | 8px | |
--space-container-padding | 32px | |
--space-container-padding-lg | 48px | |
--space-dialog-padding-mobile | 16px | |
--space-dialog-padding-tablet | 24px | |
--space-dialog-padding-desktop | 32px |
Usage
.settings-form {
display: grid;
gap: var(--space-element-gap); /* between fields */
padding: var(--space-container-padding);
}
.settings-form__actions {
display: flex;
gap: var(--space-inline-gap); /* between buttons */
margin-top: var(--space-component-gap);
}Do and don’t
Do
- Choose by relationship: fields in a form are elements, cards in a grid are components.
- Use the fluid layout tokens for page gutters and section spacing, so small screens get less.
- Use a padding token inside a box and a gap token between boxes.
Don’t
- Write
padding: 16px. The linter rejects hardcoded spacing in component CSS. - Pick a token because its value happens to be right. If the role is wrong, the next change to it will be too.
- Use margins to separate siblings when the parent can set a gap.