Skip to content
Documentation

Foundations

Spacing and size

One spacing scale for every gap and padding, density tokens that size the controls, and three corner radii. Everything is snapped to a 2 px grid.

The spacing scale

13 steps from 0 to 64 px, as --dsgn-space-<px>. Use them for every margin, gap and padding in your own CSS too: npx dsgn lint flags hard-coded pixel values. The steps are multiples of a quarter rem, rounded to 2 px, so they grow with the reader's font size and never land on half pixels.

  1. --dsgn-space-00 px
  2. --dsgn-space-22 px
  3. --dsgn-space-44 px
  4. --dsgn-space-66 px
  5. --dsgn-space-88 px
  6. --dsgn-space-1212 px
  7. --dsgn-space-1616 px
  8. --dsgn-space-2020 px
  9. --dsgn-space-2424 px
  10. --dsgn-space-3232 px
  11. --dsgn-space-4040 px
  12. --dsgn-space-4848 px
  13. --dsgn-space-6464 px

Density

Density sizes the controls and the space inside containers. Set data-density="s", "m" (default) or "l" on the page or on any section. Touch screens without a density set get L.

TokenSML
--dsgn-control-font-size141416
--dsgn-control-line-height202024
--dsgn-control-pad-y4810
--dsgn-control-pad-x121620
--dsgn-control-gap488
--dsgn-control-indicator161620
--dsgn-row-pad-y81214
--dsgn-inset121624
--dsgn-stack81216

Sizes come from type

No control has a fixed height. A button, an input or a select is its line height plus twice the vertical padding, so controls in a row always line up, and text never gets clipped when it grows.

DensityLine height+ 2 × padding= Control height
S202 × 428 px
M202 × 836 px
L242 × 1044 px
The same row in three densities
<div class="dsgn-stack" data-gap="m">
  <div class="dsgn-cluster" data-density="s"><input class="dsgn-input" aria-label="Search, density S" placeholder="Density S"><button class="dsgn-button" type="button">Search</button></div>
  <div class="dsgn-cluster" data-density="m"><input class="dsgn-input" aria-label="Search, density M" placeholder="Density M"><button class="dsgn-button" type="button">Search</button></div>
  <div class="dsgn-cluster" data-density="l"><input class="dsgn-input" aria-label="Search, density L" placeholder="Density L"><button class="dsgn-button" type="button">Search</button></div>
</div>

Corner radius

Three radii: --dsgn-radius-s for small parts (chips, checkboxes), -m for controls and -l for containers (cards, dialogs). data-radius switches all three at once.

TokenSharpDefaultRoundedPill
--dsgn-radius-s0246
--dsgn-radius-m048full
--dsgn-radius-l081624

Sharp

Default

Rounded

Pill

A button and a card in each radius mode
<div class="dsgn-grid" data-cols="1" data-cols-tablet="2" data-cols-desktop="4">
  <div class="dsgn-card" data-radius="sharp"><p class="dsgn-card-title">Sharp</p><button class="dsgn-button" type="button">Save</button></div>
  <div class="dsgn-card" data-radius="default"><p class="dsgn-card-title">Default</p><button class="dsgn-button" type="button">Save</button></div>
  <div class="dsgn-card" data-radius="rounded"><p class="dsgn-card-title">Rounded</p><button class="dsgn-button" type="button">Save</button></div>
  <div class="dsgn-card" data-radius="pill"><p class="dsgn-card-title">Pill</p><button class="dsgn-button" type="button">Save</button></div>
</div>