Skip to main content

Spacing

Our Design System uses an 8px spacing system. This system is used in our components and layouts within our products. Using this system decreases complexity of designs and creates a consistent visual rhythm across our products.

Although we describe this as an 8 'pixel' system, the spacing is in fact defined in rems.

Values

  • In Figma these are provided as 'Variables'.
  • In development these are provided as CSS custom properties.
PropertyValuepx eqv. (1rem = 16px)
--space-0-1250.0625rem1px
--space-0-250.125rem2px
--space-0-50.25rem4px
--space-10.5rem8px
--space-1-50.75rem12px
--space-21rem16px
--space-31.5rem24px
--space-42rem32px
--space-52.5rem40px
--space-63rem48px
--space-73.5rem56px
--space-84rem64px
--space-94.5rem72px
--space-105rem80px

Outliers

1px, 2px, 4px

Theses sizes are reserved for spacing within components only and for small details like borders, outlines etc.

12px

This size should be used sparingly and only within components.

Implementation

Figma

Where possible you should try to use these spacing variables in your designs in Figma, doing so will highlight these variables in dev mode, making designs a lot easier to inspect.

A screenshot of a text input being inspected, showing "space-1" in one of the gaps

Development

As long as you have the Design System added to your project then the CSS custom properties should be available to you.

Load the spacing styles into your stylesheet:

@use "@raspberrypifoundation/design-system-core/scss/properties/spacing";

Use the custom properties as follows:

.element {
padding: var(--space-2);
}