Skip to content

Margin and padding

Utility spacing scale

Spacer suffixREMPXToken
-0000
-10.125rem2px—units-25
-20.25rem4px—units-50
-30.375rem6px—units-75
-40.5rem8px—units-100
-50.75rem12px—units-150
-61rem16px—units-200
-71.25rem20px—units-250
-81.5rem24px—units-300
-92rem32px—units-400
-102.5rem40px—units-500

:::info Spacing scale Our spacing system is built around a base unit of 8 pixels :::

Margin

Spacing utility classes can be used to effect four directions — top (block-start), right (inline-end), bottom (block-end), left (inline-start). In addition, you can effect just left/right (inline) top/bottom (block). Finally, you can effect all directions at once by no specifying a direction or an axis.

Margin prefixes

Margin prefixDimensionCopy
m-all dimensions (x and y)
mt-top
mr-right
mb-bottom
ml-left
mx-x-dimension (left and right/inline)
my-y-dimension (top and bottom/block)

Padding

Padding is exactly the same as margin, simply swapping the “m” in the prefix with a “p”.

Padding prefixDimensionCopy
p-all dimensions (x and y)
pt-top
pr-right
pb-bottom
pl-left
px-x-dimension (left and right/inline)
py-y-dimension (top and bottom/block)

Breakpoint infixes

Add the viewport sizing infixes (sm, md, lg, xl, xxl) to apply at breakpoints. These infixes apply to both padding and margin.

.{prefix}-{infix}-{suffix}

XSSmallMediumLargeXLXXLCopy
.mt-6has top marginhas top marginhas top marginhas top marginhas top marginhas top margin
.mt-sm-6no top marginhas top marginhas top marginhas top marginhas top marginhas top margin
.mt-md-6no top marginno top marginhas top marginhas top marginhas top marginhas top margin
.mt-lg-6no top marginno top marginno top marginhas top marginhas top marginhas top margin
.mt-xl-6no top marginno top marginno top marginno top marginhas top marginhas top margin
.mt-xxl-6no top marginno top marginno top marginno top marginno top marginhas top margin

Responsiveness

Below is an illustration of the responsive cascade. The pattern follows the “mobile first” model.

XSSmallMediumLargeXLXXLCopy
m-2—units-50—units-50—units-50—units-50—units-50—units-50
m-2 m-sm-4—units-50—units-100—units-100—units-100—units-100—units-100
m-2 m-sm-4 m-md-6—units-50—units-100—units-200—units-200—units-200—units-200
m-2 m-sm-4 m-md-6 m-lg-8—units-50—units-100—units-200—units-300—units-300—units-300
m-2 m-sm-4 m-md-6 m-lg-8 m-xl-9—units-50—units-100—units-200—units-300—units-400—units-400
m-2 m-sm-4 m-md-6 m-lg-8 m-xxl-10—units-50—units-100—units-200—units-300—units-400—units-500