Margin

Margin utilities are based on a global spacing scale which helps keep horizontal and vertical spacing consistent. These utilities help us reduce the amount of custom CSS that share the same properties, and allows to achieve many different page layouts using the same styles.

Naming convention

Since margin utilities have many variations and will be used in many places, we use a shorthand naming convention to help keep class names succinct.

ShorthandDescription
mmargin
ttop
rright
bbottom
lleft
xhorizontal, left & right
yvertical, top & bottom
00
14px
28px
316px
424px
532px
640px
748px
864px
980px
1096px
11112px
12128px

Uniform margins

Use uniform spacing utilities to apply equal margin to all sides of an element. These utilities can change or override default margins, and can be used with a spacing scale from 0-6.

View in Storybook

Directional margins

Use directional utilities to apply margin to an individual side, or the X and Y axis of an element. Directional utilities can change or override default margins, and can be used with a spacing scale of 0-6.

View in Storybook

Extended vertical margins

The extended scale starts from spacer 7 up to 12. Note: Only the y-axis (mt, mb and my) and its responsive variants are supported.

View in Storybook

Center elements

Use mx-autoto center block elements with a set width.

View in Storybook

We also provide directional margin auto. mt-auto, mr-auto, mb-auto, ml-auto

View in Storybook

Reset margins

Reset margins built into typography elements or other components with m-0, mt-0, mr-0, mb-0, ml-0, mx-0, and my-0.

View in Storybook

Responsive margins

All margin utilities can be adjusted per breakpoint using the following formula: m[direction]-[breakpoint]-[spacer]. Each responsive style is applied to the specified breakpoint and up.

View in Storybook

Negative margins

You can add negative margins to the top, right, bottom, or left of an item by adding a negative margin utility. The formula for this is: m[direction]-n[spacer], where spacer runs from 1 to 6. This also works responsively, with the following formula: m[direction]-[breakpoint]-n[spacer].

View in Storybook

Extended negative margins

You can use the extended spacing scale for top and bottom margins, ranging from 1 to 12.

View in Storybook