Skip to main content

Spacing units

Spacing unit tokens, based on multiples of 8px



Properties

Positive units

Utility class Multiple Pixels Example
1px 1px
2px 2px
0.5, '05' 0.5 4px
1 1 8px
1.5, '105' 1.5 12px
2 2 16px
2.5, '205' 2.5 20px
3 3 24px
4 4 32px
5 5 40px
6 6 48px
7 7 56px
8 8 64px
9 9 72px
10 10 80px
15 15 120px

Negative units

Utility class Multiple Pixels
-1px, 'neg-1px' -1px
-2px, 'neg-2px' -2px
-0.5, 'neg-05' -0.5 -4px
-1, 'neg-1' -1 -8px
-1.5, 'neg-105' -1.5 -12px
-2, 'neg-2' -2 -16px
-2.5, 'neg-205' -2.5 -20px
-3, 'neg-3' -3 -24px
-4, 'neg-4' -4 -32px
-5, 'neg-5' -5 -40px
-6, 'neg-6' -6 -48px
-7, 'neg-7' -7 -56px
-8, 'neg-8' -8 -64px
-9, 'neg-9' -9 -72px
-10, 'neg-10' -10 -80px
-15, 'neg-15' -15 -120px

Breakpoint units

Token Multiple Pixels
'card' 20 160px
'card-lg' 30 240px
'mobile' 40 320px
'mobile-lg' 60 480px
'tablet' 80 640px
'tablet-lg' 110 880px
'desktop' 128 1024px
'desktop-lg' 150 1200px
'widescreen' 175 1400px


Utility classes

Utility classes may be included in your HTML or applied using Utility classes in your Sass.

Spacing units are used in conjunction with: border, height, width, margin, padding, shape, indentation, and relative position.

Utility Example Code
.border-units .border-2px class=("border-2px")
.height-units .height-05 class=("height-05")
.width-units .width-05 class=("width-05")
.margin-units .margin-05 class=("margin-05")
.padding-units .padding-05 class=("padding-05")
.shape-units .shape-05 class=("shape-05")
.text-indent-units .text-indent-4 class=("text-indent-4")
.bottom-units .bottom-05 class=("bottom-05")

  • Use single-quoted strings in Utility classes.
  • Do not quote numbers or px values. With the exception of half (05), values like '105', and '205' should be treated as strings.
  • String tokens for half values (like 05) and negative values (like neg-1) may also be written with their unquoted number token equivalent: 0.5, 1.5, 2.5, -1, -1.5, etc.
  • If multiple utilities share the same prefix (ex: .text- or .flex-) or a single utility accepts multiple kinds of values (ex: .border accepts both border weight and border color), their shared mixin can accept multiple comma-separated values:
    • u-text('primary-darkest', 'no-underline', 'bold')
    • u-border-top(2px, 'accent-warm')
  • Output any utility mixin as !important by appending !important to the mixin’s argument list:
    • u-bg('red-warm-50v', !important)


Utility variants

More information about utility variants can be viewed on the utility variants page. Responsive and state variants are listed as true when they are available for use.

Responsive variants

You can apply different styles at differentresponsive breakpoints using responsive utilities. Use a breakpoint prefix separated with a : to target a utility at a responsive breakpoint and higher (eg. .desktop:border-05).

Utility variable Responsive
$font-style-settings false

State variants

You can apply different styles for different state variants using state utilities. Use a state prefix separated with a : to target a utility for a specific state. (eg. .hover:shadow-2).

Utility variable Active Focus Hover Visited
$font-style-settings false false false false
Looking for U.S. government information and services?
Visit USA.gov