Guidelines

Spacing

Spacing tokens are used to consistently apply margin and padding across components and UIs. Having a set spacing scale brings a rhythm to the product and creates a natural and familiar flow from page to page.

Two spacing scales

We use two spacing scales:

  • inner spacing: spacing within components
  • layout spacing: the position of the components in the layout and defining relationships between them.

The spacing system needs to be in harmony with the typography and the components. For spacing tokens to be able to conform in the baseline grid and contribute to the vertical rhythm, all sizes must be divisible by 4. The spacing tokens always refer to fixed values (are not responsive). All spacing tokens can be used as values for margins or paddings.

Use of space

We use space to create hierarchy and relationships. By using space we can create proximity, grouping and relationships between components that establish a visual hierarchy that can organize information and improve the user experience.

Inner component scale

Whenever we need a fixed horizontal or vertical spacing inside components then these spacing tokens are to be used. All the values are multiple of 4px so they can complement with the typography and placed in a 4px vertical grid.

NameToken (example)Size
4xl$spacing-4xl4rem - 64px
3xl$spacing-3xl3rem - 48px
2xl$spacing-2xl2.5rem - 40px
xl$spacing-xl2rem - 32px
l$spacing-lg1.5rem - 24px
m$spacing-md1rem - 16px
s$spacing-sm0.75rem - 12px
xs$spacing-xs0.5rem - 8px
2xs$spacing-2xs0.25rem - 4px
 Space token of components

Layout scale

Whenever we need a fixed horizontal or vertical spacing to place components in a layout then the below tokens need to be used. In most cases, the horizontal spacing is been determined to be the 12 column horizontal grid (If there are cases of fixed horizontal spacing then the tokens need to be used). So the layout spacing tokens are used mostly to define the vertical relationships between components. These spaces are always fixed (thus we use the tokens). In annotations, these spacings will be green overlays.

NameToken (example)Size
4xl$layout-4xl4rem - 64px
3xl$layout-3xl3rem - 48px
2xl$layout-2xl2.5rem - 40px
xl$layout-xl2rem - 32px
l$layout-lg1.5rem - 24px
m$layout-md1rem - 16px
s$layout-sm0.75rem - 12px
xs$layout-xs0.5rem - 8px
2xs$layout-2xs0.25rem - 4px
 Space token of layouts