Spacing

Consistent spacing helps arrange the content of a screen in a clean and predictable way.

Consistent spacing across our pages and components creates a polished experience that’s easy for users to visually scan and understand.

Individual elements should only control spacing inside of their boundary through padding (that is, with the App UI Kit Box component).

For spacing between elements, you should:

  • Apply padding on the parent container (with Box).
  • Use layout components (for example, Rows, Columns) and set spacing on those.
  • Iframe margins should be 16px across all devices.

  • Spacing above and below a search bar should be 16px.

  • Use smaller spacing between related components in a section. For example, spacing between content in a grid and carousel section should be 8px.

  • Use larger spacing to communicate separation between components or sections. For example, the distance between each section (search pills, carousels, results) should be 24px.

    Spacing reference for the distance between components

  • Use inconsistent spacing for similar components (for example, keep spacing between the labels and their components consistently 4px).
  • Use margins on individual elements — spacing between elements should be managed by spacing in layout components.

The following is a scale we use to define the size of spacing throughout our products. Implement this spacing scale using the spacing prop in the App UI Kit Rows and Columns layout components, as well as through importing CSS and Typescript/JavaScript variables directly.

The scale is based on a base unit of 8px.

Grid unitsName (CSS)Name (React)Pixels
0
--ui-kit-space-0
space0
0px
0.5u
--ui-kit-space-050
space050
4px
1u
--ui-kit-space-1
space1
8px
1.5u
--ui-kit-space-150
space150
12px
2u
--ui-kit-space-2
space2
16px
3u
--ui-kit-space-3
space3
24px
4u
--ui-kit-space-4
space4
32px
6u
--ui-kit-space-6
space6
48px
8u
--ui-kit-space-8
space8
64px
12u
--ui-kit-space-12
space12
96px