Skip to content

Spacers โ€‹

The spacing scale is designed to complement the existing components and typography throughout the system.
By using the correct spacing scale when building individual components, we maintain the proper spatial relation between elements and components.

overview

Usage Guidelines โ€‹

Spacing components can be inserted into your Figma design file as guides to properly space elements and other components.

When to use โ€‹

  • To set vertical and horizontal spacing between elements and components.
  • To group elements or components using the same spacing.
  • To connect elements or components to show the relation between them.
  • To define a hierarchy

When not to use โ€‹

  • Don't use big spacings if you want to show a relation between elements.
  • Don't use different spacings to group the same components.

Specifications โ€‹

Anatomy โ€‹

anatomy

Spacing element: comes in sizes from 2 to 160 pixels. The 16x16 pixel component is named Spacing-100, being 100% of 1 rem, or 16px (the base line font size for ZDS). The rest of the components are named Spacing-XX, from Spacing-125 (12.5% or x1/8, 2 pixels) to Spacing-1000 (1000% or x10, 160 pixels), XX being the corresponding percentage in relation to the 100% of 16 pixels.

They have a bright color to stand out from your design elements and should be removed when completed.

Sizes โ€‹

For general spacing within components (inlet) use spacings from Spacing-12 to Spacing-300, and for layout spacing between different elements (outlet) use from Spacing-50 to Spacing-1000.

sizes

Variables โ€‹

Additionally, Spacings are included as Figma variables, named sp-125 to sp-1000, for ease of use within custom components.

Grid gutter โ€‹

Apart from the regular spacings, there's an additional spacing variable, called #sp-grid-gutter, of 30px, the same size as the gutters between columns (see Grid foundations), to be used exclusively in horizontal auto-layout spacings of components that are based on the baseline grid.

Principles โ€‹

A layout consists of UI elements and components and the space between them. Use spacing principles to help users understand the relation between elements and components.

Group by affiliation โ€‹

You should use consistent spacing around elements to show a visual similarity and relation between them. Examples for this are lists and tables.

Use consistent spacings
Don't use different spacings for elements in lists

Group by proximity โ€‹

If you want to show a relation between elements/components, place them close to each other.

Use consistent spacings.
Don't use different spacings for elements in lists.

Create order and hierarchy โ€‹

To quickly understand the relation between elements/components, it is important to define a hierarchy so users can follow a journey or flow easier.

Root size โ€‹

Almost all the sizes in the ZDS are relative (rem) for responsiveness and accessibility. The default root size (based on the 100 spacer) for web it's 16px, but this value can be adapted depending on the needs or accessibility configuration. The values recommended are the even number between 12 and 20.

You can change this value directly in the documentation to preview the sizes in here.

Code-wise, you just need to change the value of font-size in the :root element in CSS to make the scaling:

css
:root {
  font-size: 12px;
}

CSS tokens โ€‹

These are the values provided as part of the @zurich/design-tokens NPM library:

NamePixelsREMFigma variableCSS tokenSample
122 px0.125 rems-12--zs-12
254 px0.25 rems-25--zs-25
508 px0.5 rems-50--zs-50
7512 px0.75 rems-75--zs-75
10016 px1 rems-100--zs-100
15024 px1.5 rems-150--zs-150
20032 px2 rems-200--zs-200
25040 px2.5 rems-250--zs-250
30048 px3 rems-300--zs-300
40064 px4 rems-400--zs-400
60096 px6 rems-600--zs-600
1000160 px10 rems-1000--zs-1000