Skip to content

Design tokens / Spacing

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.

ScaleGovernsUsed by
--spacing-*margins and gaps between elements<kb-stack>'s gap, layout rhythm
--spacing_inset-*padding inside an elementevery component's own padding

Spacing ​

Standardizes composition and the vertical rhythm of an interface.

TokenValueSample
--spacing-quarck4px
--spacing-nano8px
--spacing-xxxs16px
--spacing-xxs24px
--spacing-xs32px
--spacing-sm40px
--spacing-md48px
--spacing-lg56px
--spacing-xl64px
--spacing-xxl80px
--spacing-xxxl120px
--spacing-huge160px
--spacing-giant200px

Inset ​

Inner spacing — the padding of a component, where all four sides are equal.

TokenValueSample
--spacing_inset-quarck4px
--spacing_inset-nano8px
--spacing_inset-xs16px
--spacing_inset-sm24px
--spacing_inset-md32px
--spacing_inset-lg40px
--spacing_inset-huge48px
--spacing_inset-giant56px

?> 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:

preview
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>
StepUse for
quarck / nanoElements that read as one unit — an icon and its label, a field and its helper.
xsThe default: siblings inside a group.
sm / mdSeparating groups from each other inside a section.
lg and upSection-level separation.