London City Data

Spacing

One scale for the space inside components

Spacing is one numbered scale for the space inside a component, such as padding, a border or an indent.

Each step is a multiple of 4px, so --spacing-4 is 16px. The space between blocks of content, such as between two paragraphs or two cards, uses flow instead.

Use

The components use the spacing scale already. In your own components, use the custom properties:

.legend-item {
	display: flex;
	gap: var(--spacing-2);
	padding: var(--spacing-1-5) var(--spacing-3);
}

If your app uses Tailwind, as the component library does, the theme package's preset sets Tailwind's spacing utilities to the scale. p-4 is var(--spacing-4), and a half step keeps Tailwind's dot, as in mt-1.5.

Tailwind's own steps that aren't on the scale, such as p-9 or p-28, still work, but they aren't tokens. Use a step from the scale.

How it works

The scale

The whole steps run from --spacing-1 (4px) to --spacing-8 (32px), then 10, 12, 14, 16, 20 and 24, up to 96px.

Below 16px there are half steps for finer control: --spacing-0-5 (2px), --spacing-1-5 (6px), --spacing-2-5 (10px) and --spacing-3-5 (14px). --spacing-px is 1px.

--spacing-14px
--spacing-28px
--spacing-312px
--spacing-416px
--spacing-624px
--spacing-832px
--spacing-1248px
--spacing-1664px
--spacing-2496px

Use the semantic token, --spacing-{n}, not the primitive it points to.

Spacing or flow

Space that builds a component, such as padding, a border or an indent, uses the spacing scale. Space between blocks of content uses flow, which changes with its context.

To decide, ask whether the space is inside a block or between blocks. The space between a form field's label, input and hint builds the field, so it uses spacing. The space between one field and the next is flow, and so is the gap between tiled cards. The gap between a button's icon and its label is spacing.

In this card, the padding is spacing and the space between the title and the paragraph is flow:

<div class="card flow-standard">
	<h3 class="card-title">Housing completions</h3>
	<p class="body-md">Net additional homes in each borough, 2015 to 2025.</p>
</div>
.card {
	padding: var(--spacing-4);
	border: 1px solid var(--color-border-wash);
	background: var(--color-surface);
}

Housing completions

Net additional homes in each borough, 2015 to 2025.

The flow between the card's blocks comes from flow-standard, which the card sets.

Reference

TokenValuePixels
--spacing-px0.0625rem1px
--spacing-0-50.125rem2px
--spacing-10.25rem4px
--spacing-1-50.375rem6px
--spacing-20.5rem8px
--spacing-2-50.625rem10px
--spacing-30.75rem12px
--spacing-3-50.875rem14px
--spacing-41rem16px
--spacing-51.25rem20px
--spacing-61.5rem24px
--spacing-71.75rem28px
--spacing-82rem32px
--spacing-102.5rem40px
--spacing-123rem48px
--spacing-143.5rem56px
--spacing-164rem64px
--spacing-205rem80px
--spacing-246rem96px

The full rules for spacing are in the specification.