Spacing
Two scales, defined in packages/pixel/tokens/spacing.css. Keeping them separate is the point: an adjustment to the space between elements never changes a component's inner breathing room.
| Scale | Governs | Used by |
|---|---|---|
--spacing-* | margins and gaps between elements | <kb-stack>'s gap, layout rhythm |
--spacing_inset-* | padding inside an element | every component's own padding |
Spacing
Standardizes composition and the vertical rhythm of an interface.
| Token | Value | Sample |
|---|---|---|
--spacing-quarck | 4px | |
--spacing-nano | 8px | |
--spacing-xxxs | 16px | |
--spacing-xxs | 24px | |
--spacing-xs | 32px | |
--spacing-sm | 40px | |
--spacing-md | 48px | |
--spacing-lg | 56px | |
--spacing-xl | 64px | |
--spacing-xxl | 80px | |
--spacing-xxxl | 120px | |
--spacing-huge | 160px | |
--spacing-giant | 200px |
Inset
Inner spacing — the padding of a component, where all four sides are equal.
| Token | Value | Sample |
|---|---|---|
--spacing_inset-quarck | 4px | |
--spacing_inset-nano | 8px | |
--spacing_inset-xs | 16px | |
--spacing_inset-sm | 24px | |
--spacing_inset-md | 32px | |
--spacing_inset-lg | 40px | |
--spacing_inset-huge | 48px | |
--spacing_inset-giant | 56px |
?> The two scales share step names up to nano but diverge after: --spacing-xs is 32px while --spacing_inset-xs is 16px. Reading a step name without its scale tells you nothing — always carry the prefix.
In practice
<kb-stack>'s spacing attribute resolves against the inset scale, which is what keeps a gap inside a group proportional to the padding around it:
Code
html
<kb-stack direction="column" spacing="nano" align="stretch">
<kb-card>
<kb-text size="xxs">Gap of spacing_inset-nano between these cards</kb-text>
</kb-card>
<kb-card>
<kb-text size="xxs">…and the card's own padding is spacing_inset-xs</kb-text>
</kb-card>
</kb-stack>| Step | Use for |
|---|---|
quarck / nano | Elements that read as one unit — an icon and its label, a field and its helper. |
xs | The default: siblings inside a group. |
sm / md | Separating groups from each other inside a section. |
lg and up | Section-level separation. |