No Preview

Sorry, but you either have no stories or none are selected somehow.

If the problem persists, check the browser console, or the terminal you've run Storybook from.

Spacing

Space may be invisible, but the concept is critical to good interface design by establishing relationships and influencing visual style.

The scale

Root's spacing system consists of 9 spacing variables.

SizeVariableValue
100--ab-spacing-1004px
200--ab-spacing-2008px
300--ab-spacing-30016px
400--ab-spacing-40024px
500--ab-spacing-50032px
600--ab-spacing-60040px
700--ab-spacing-70048px
800--ab-spacing-80056px
900--ab-spacing-90064px

The spacing variables can be applied to margin or padding properties like this:

.component__title {
  margin-bottom: var(--ab-spacing-200);
  padding-top: var(--ab-spacing-400);
}

Applying spacing

To add spacing around something you can use the ab-container utility component. It allows you to apply both padding and margin by using certain modifiers.

Individual components in Root should not have margins or paddings on the "outside". This means that all spacing between components can be applied by wrapping components inside the ab-container.

Example

Show source
Oh no! The source is not available.

Padding

Class (CSS)Attribute (Web Component)Type
ab-container--p-{100 to 900}p="100 to 900"Padding on all sides
ab-container--px-{100 to 900}px="100 to 900"Horisontal padding
ab-container--py-{100 to 900}py="100 to 900"Vertical padding
ab-container--pt-{100 to 900}pt="100 to 900"Top padding
ab-container--pb-{100 to 900}pb="100 to 900"Bottom padding
ab-container--pl-{100 to 900}pl="100 to 900"Left padding
ab-container--pr-{100 to 900}pr="100 to 900"Right padding

Margin

ClassAttribute (Web Component)Type
ab-container--m-{100 to 900}m="100 to 900"Margin on all sides
ab-container--mx-{100 to 900}mx="100 to 900"Horisontal margin
ab-container--my-{100 to 900}my="100 to 900"Vertical margin
ab-container--mt-{100 to 900}mt="100 to 900"Top margin
ab-container--mb-{100 to 900}mb="100 to 900"Bottom margin
ab-container--ml-{100 to 900}ml="100 to 900"Left margin
ab-container--mr-{100 to 900}mr="100 to 900"Right margin