Skip to content

Spacing

Space variables are defined in the Figma library and exposed through CSS variables. All CSS variables are prefixed with cim, so for example space-8 becomes --cim-space-8. These variables can be used directly in your CSS:

.title {
margin-bottom: var(--cim-space-8);
}

Or through the component API available on nearly all components:

<div>
<Text as="h1" variant="title-1" marginBottom={24}>
Title text
</Text>
<Text as="p">Commodo proident dolor cillum ea sint.</Text>
</div>

Lastly, the Stack component provides an easy way to create consistent spacing between elements. It uses the same spacing tokens and allows you to stack elements vertically or horizontally with a specified gap between them:

<Stack gap={24}>
<Text as="h1" variant="title-1">
Title text
</Text>
<Text as="p">Commodo proident dolor cillum ea sint.</Text>
</Stack>
TokenValueSize
space-00pxExtra small
space-22pxExtra small
space-44pxExtra small
space-88pxSmall
space-1212pxSmall
space-1616pxSmall
space-2424pxMedium
space-3232pxMedium
space-4040pxMedium
space-4848pxLarge
space-6464pxLarge
space-9696pxLarge

In isolation, spacing variables don’t provide much value. It is the way spacing is used to create visual relationships between elements in a page that creates visual hierarchy. The way variables are used should be purposeful to shape the page’s layout.

Our spacing system is broken down into four sizes for our spacing variables: extra small, small, medium, large.

These units are used within components between elements that have only a slight gap between them. Outside of individual component design, they should not be used as they are too small to be impactful for most elements.

Examples:

  • Space between lines in an icon

These units are used within components and smaller composed UI elements. They are used for elements that are directly related to each other.

Examples:

  • Space between elements within a card
  • An information icon directly following a piece of text
  • Space between related buttons next to each other (Save and Cancel, Next and Back)
  • Horizontal and vertical space between related form elements

The units are used to separate UI blocks that might be related or follow each other in a flow, but do not share the same information or function.

Examples:

  • Space between sections in a form
  • Space between a header and following content

These units are used to separate large page areas or provide vertical or horizontal page margins.

Examples

  • The bottom margin of a page’s content area