Skip to main content

Spacing, radius & density

Prism never forks for a new audience. It reconfigures. The same components retune from a phone to a television, and from an airy onboarding flow to a dense admin table, by changing which values a small set of role tokens point at.

Spacing ruler & density​

The 4px scale, the radius ladder, and the same controls at compact / neutral / relaxed. The density columns render real components, so the rhythm change is the system itself. Click a bar or radius tile to copy its token.

Signature
Density
Viewport
Theme and light/dark are set in the top bar
Live demo
Open ↗

Two layers​

Primitives are the 4px grid: --space-1 (4px) through --space-32 (128px), with two half-steps (--space-0-5, --space-1-5) for tight insets. Components do not use these directly for layout.

Roles say what a space is for. They point at a primitive, and which one depends on the device tier and the density. Layout is written in roles, so one attribute reflows a whole product.

The spacing roles​

The five gaps form a ladder that always increases: things that belong together sit closer than things that do not.

RoleWhat it separatesMobileTabletDesktopCinema
--gap-inlineparts of one unit: icon and label, buttons in a group88812
--gap-stacklines in one block: label to input, heading to text12161624
--gap-groupsibling blocks: field to field, card to card24242440
--gap-sectionpage sections32404864
--gap-pagethe content column from what is above and below it48648096
--layout-gutterpage edge padding16243264
--pad-cardinside a card16202440
--pad-surfaceinside a dialog, drawer or panel20243248
--pad-control-x / -yinside a control16 / 816 / 816 / 824 / 12
--control-heightbuttons, inputs, selects40404056

All values are pixels at neutral density.

The radius roles​

RoleUsed onMobileTablet and desktopCinema
--radius-controlbuttons, inputs, chips5812
--radius-cardcards, tiles81216
--radius-surfacedialogs, drawers, large panels121624
--radius-mediaimages and video81216

--radius-pill is reserved for switches, avatars and removable tags.

When one rounded shape sits inside another, use --radius-inset-card or --radius-inset-surface for the inner one. They subtract the padding from the outer radius so the two curves stay parallel.

Themes may set their own radii. Industry is tighter and squarer than the base theme, for example. Components that use the roles follow without change.

Device tiers​

TierTriggerCharacter
mobilebasetightest spacing and radius, touch targets, one column
tablet≥ 640pxslightly larger type and spacing
desktop≥ 1024pxfull layout, widest gutters
cinemadata-scale="cinema" (or "tv")large type, 56px controls, for screens read from across a room

The first three follow the viewport width. Cinema never switches on by itself: a large monitor is still a desktop. The application sets data-scale="cinema" on <html> or on any part of the page, which also lets a television preview render at the right scale inside a desktop admin.

Density​

Set data-density on <html> or any part of the page to trade whitespace for information.

DensityUse forStack / group / section gapCard paddingControl height
compactadmin tables, reports, finance dashboards8 / 16 / 241232
neutralthe defaultby tier, as aboveby tier40
relaxedapplications, onboarding, reading16 / 32 / 643248

Density changes spacing and control height. It does not change font sizes.

How they compose​

<html data-density="compact"> <!-- dense by default -->
<section data-density="relaxed"> … </section> <!-- one airy panel -->
<aside data-scale="cinema"> … </aside> <!-- a television preview -->

Each attribute applies to its own subtree, so they mix freely at any level with no per-component code.

Authoring rules​

  • A grid of tiles reads --gap-tile first. Write gap: var(--gap-tile, var(--gap-group)) on a dashboard grid or any grid of cards. Only a tiled theme sets the token (Industry: 4px, so tiles sit almost flush); everywhere else the fallback applies. Never use it between form fields.
  • Never hand-pick a padding or a radius. Use the role: --pad-card, --gap-group, --gap-stack, --control-height, --radius-card. It already resolves for the tier and the density.
  • Space groups before borders do. The gap between groups is at least twice the gap within one.
  • Touch targets should be at least 44px (--size-touch). Default controls are 40px tall, and 32px at compact, so on touch surfaces use the lg size or relaxed density.
  • Do not edit tokens/scales.css. The roles are generated from tokens/scale.config.json; change that file and regenerate.
  • Check each screen at all three densities and at the cinema tier.

Live specimens​

Spacing scale

Live demo
Open ↗

Size tiers · mobile → cinema

Live demo
Open ↗

Density scale

Live demo
Open ↗

Control sizing

Live demo
Open ↗

Radius

Live demo
Open ↗