Utilities

Text styles

Change the appearance of text. (Not all text styles are available in every typeface.)

CSS properties

font-feature-settings font-style font-weight letter-spacing text-decoration text-decoration-color text-transform vertical-align white-space

Examples and usage

Utilities, values, and variants may be activated and deactivated in advanced settings.

Font style

CSS property: font-style

  • responsive
  • active
  • hover
  • focus
  • visited

.text-italic

.text-no-italic

Font weight

CSS property: font-weight

.text-thin

.text-light

.text-normal

.text-medium (Note: not included in default set)

.text-semibold

.text-bold

.text-heavy

Letterspacing

CSS property: letter-spacing

  • responsive
  • active
  • hover
  • focus
  • visited

.text-ls-neg-3 -0.03em

.text-ls-neg-2 -0.02em

.text-ls-neg-1 -0.01em

.text-ls-auto initial

.text-ls-1 0.05em

.text-ls-2 0.1em

.text-ls-3 0.15em

Tabular numerals

CSS property: font-feature-settings

  • responsive
  • active
  • hover
  • focus
  • visited

123,456,789

825,489,012

112,051,928

.text-tabular

Note: not included in default set

123,456,789

825,489,012

112,051,928

.text-no-tabular

Text decoration

CSS property: text-decoration

  • responsive
  • active
  • hover
  • focus
  • visited

.text-underline

.text-strike

.text-no-strike

.text-no-underline

Text decoration color

CSS property: text-decoration-color

  • responsive
  • active
  • hover
  • focus
  • visited
.underline-base-lightest.text-underline gray-5 #f0f0f0
.underline-base-lighter.text-underline gray-cool-10 #dcdee0
.underline-base-light.text-underline gray-cool-30 #a9aeb1
.underline-base.text-underline gray-cool-50 #71767a
.underline-base-dark.text-underline gray-cool-60 #565c65
.underline-base-darker.text-underline gray-cool-70 #3d4551
.underline-base-darkest.text-underline gray-90 #1b1b1b
.underline-ink.text-underline gray-90 #1b1b1b
.underline-primary-lighter.text-underline blue-10 #d9e8f6
.underline-primary-light.text-underline blue-30 #73b3e7
.underline-primary.text-underline blue-60v #005ea2
.underline-primary-vivid.text-underline blue-warm-60v #0050d8
.underline-primary-dark.text-underline blue-warm-70v #1a4480
.underline-primary-darker.text-underline blue-warm-80v #162e51
.underline-secondary-lighter.text-underline red-cool-10v #f8dfe2
.underline-secondary-light.text-underline red-30 #f2938c
.underline-secondary.text-underline red-50 #d83933
.underline-secondary-vivid.text-underline red-cool-50v #e41d3d
.underline-secondary-dark.text-underline red-60v #b51d09
.underline-secondary-darker.text-underline red-70v #8b1303
.underline-accent-cool-lighter.text-underline blue-cool-5v #e1f3f8
.underline-accent-cool-light.text-underline blue-cool-20v #97d4ea
.underline-accent-cool.text-underline cyan-30v #00bde3
.underline-accent-cool-dark.text-underline blue-cool-40v #28a0cb
.underline-accent-cool-darker.text-underline blue-cool-60v #07648d
.underline-accent-warm-lighter.text-underline orange-10 #f2e4d4
.underline-accent-warm-light.text-underline orange-20v #ffbc78
.underline-accent-warm.text-underline orange-30v #fa9441
.underline-accent-warm-dark.text-underline orange-50v #c05600
.underline-accent-warm-darker.text-underline orange-60 #775540

Uppercase and lowercase

CSS property: text-transform

  • responsive
  • active
  • hover
  • focus
  • visited

.text-uppercase

.text-lowercase

.text-no-uppercase

.text-no-lowercase

Vertical alignment

CSS property: vertical-align

  • responsive
  • active
  • hover
  • focus
  • visited

A line of text and .text-baseline

A line of text and .text-bottom

A line of text and .text-middle

A line of text and .text-sub

A line of text and .text-super

A line of text and .text-tbottom

A line of text and .text-ttop

A line of text and .text-top

Whitespace formatting

CSS property: white-space

  • responsive
  • active
  • hover
  • focus
  • visited

.text-pre formatted line with multiple spaces

.text-pre-line formatted line with multiple spaces

.text-pre-wrap formatted line with multiple spaces

.text-wrap formatted line with multiple spaces

.text-no-wrap formatted line with multiple spaces

Utility Mixin Example
.text-style u-text(style) @include u-text('italic')
.text-weight u-text(weight) @include u-text('light')
.text-tabular u-text('tabular') @include u-text('no-tabular')
.text-decoration u-text(decoration) @include u-text('underline')
.underline-color u-underline(color) @include u-underline('primary-vivid')
.text-case u-text(case) @include u-text('uppercase')
.text-vertical-align u-text(vertical-align) @include u-text('ttop')
multiple text utilities... u-text(token, token, token...) @include u-text('uppercase', 'primary-darker', 'no-wrap', 'italic', 'bold', 'no-underline')

Utility mixins

Utilities may be used in component Sass with utility mixins. Highlighted tokens are the USWDS design tokens that serve as the foundation for all design system styles. Each token is also a documentation link. Consult the Design tokens section for more information on tokens and how to use them in USWDS.

Utility
Mixin
Example
.text-style
u-text(style)
u-text('italic') u-text('no-italic')
.text-weight
u-text(weight)
u-text('thin') u-text('normal') u-text(900)
.text-ls-value
u-text('ls-value'')
u-text('ls-1') u-text('ls-auto') u-text('ls-neg-1')
.text-tabular
u-text('tabular')
u-text('tabular') u-text('no-tabular')
.text-decoration
u-text('decoration')
u-text('underline') u-text('strike') u-text('no-underline')
.underline-color
u-underline(color)
u-underline('secondary-dark') u-underline('red-50v')
.text-case
u-text(case)
u-text('uppercase') u-text('lowercase') u-text('no-uppercase')
.text-vertical-align
u-text(vertical-align)
u-text('baseline') u-text('sup') u-text('ttop')
.text-white-space
u-text(white-space)
u-text('pre-line') u-text('no-wrap') u-text('wrap')

Using utility mixins

  • Use single-quoted strings in utility mixins. Do not quote numbers or px values, with the exception of half (05) values like '05', '105', and '205' which should be treated as strings.
  • String tokens for half values (05) and negative values (like neg-1)may also be written with their unquoted number token equivalent: 0.5, 1.5, 2.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') or 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).

Advanced settings

Responsive variants

Add a responsive breakpoint prefix separated with a : to target a utility at a responsive breakpoint and higher, following a mobile-first methodology.

Set which breakpoints are available to USWDS utilities with the $theme_output_breakpoints variable found in _uswds-theme-utilities.scss.

Breakpoint name Width Default
card 160px false
card-lg 240px false
mobile 320px false
mobile-lg 480px true
tablet 640px true
tablet-lg 880px false
desktop 1024px true
desktop-lg 1200px false
widescreen 1400px false

Set whether a utility family outputs with responsive variants by setting the value of $[utility_family]-settings.responsive in _uswds-theme-utilities.scss.

Utility variable Default
$font-style-settings.responsive false
$font-weight-settings.responsive true
$letter-spacing-settings.responsive false
$font-feature-settings-settings.responsive false
$text-decoration-settings.responsive false
$text-decoration-color-settings.responsive false
$text-transform-settings.responsive false
$vertical-align-settings.responsive false
$whitespace-settings.responsive false

State variants

Use a state prefix separated with a : to target a utility in a specific state.

Set whether a utility outputs a specific state variant by setting the value of the $[utility_family]-settings.[state] variable in _uswds-theme-utilities.scss.

Utility variable active focus hover visited
$font-style-settings false false false false
$font-weight-settings false false false false
$letter-spacing-settings false false false false
$font-feature-settings-settings false false false false
$text-decoration-settings false false true false
$text-decoration-color-settings false false true false
$text-transform-settings false false false false
$vertical-align-settings false false false false
$whitespace-settings false false false false

Output control

Control whether or not to output any USWDS utility family by setting the value of the $[utility_family]-settings.output variable found in _uswds-theme-utilities.scss.

A value of true will output the utility family and any variants. A value of false prevents the output of the family and any variants.

Utility variable Default
$font-style-settings.output true
$font-weight-settings.output true
$letter-spacing-settings.output true
$font-feature-settings-settings.output true
$text-decoration-settings.output true
$text-decoration-color-settings.output true
$text-transform-settings.output true
$vertical-align-settings.output true
$whitespace-settings.output true

Custom values

By default, USWDS utilities output the standard values listed in the documentation above. Customize and refine any utility family’s specific values by editing the $[utility_family]-manual-values and $[utility_family]-palettes variables in _uswds-theme-utilities.scss.

Manual values

Specify manual values as unique key:value pairs using the $[utility_family]-manual-values map, where the key is the utility’s value suffix, and the value is what the utility will output.

Palettes

Palettes are predefined groups of values. Add palettes to the $[utility_family]-palettes list variable in _uswds-theme-utilities.scss to add those values to the utility family.

Color palettes

In the following table, family indicates a specific unquoted system color family token (like blue-warm) as documented on the system color tokens page.

Palette name Palette contents
'palette-color' All color tokens
'palette-color-default' System default color tokens
'palette-color-theme' All theme color tokens
'palette-color-state' All state color tokens
'palette-color-grayscale' gray-5, gray-10, gray-30, gray-50, gray-70, gray-90
'palette-color-basic' All basic colors
'palette-color-system' All grades in all system color tokens
'palette-color-system-family' All grades in the specified family
'palette-color-system-family-light' Grades 5, 10, 20, 30
'palette-color-system-family-light-vivid' Grades 5v, 10v, 20v, 30v
'palette-color-system-family-medium' Grades 40, 50, 60
'palette-color-system-family-medium-vivid' Grades 40v, 50v, 60v
'palette-color-system-family-dark' Grades 70, 80, 90
'palette-color-system-family-dark-vivid' Grades 70v, 80v, 90v
'palette-color-system-family-standard' Grades 5, 10, 20, 30, 40, 50, 60, 70, 80, 90
'palette-color-system-family-vivid' Grades 5v, 10v, 20v, 30v, 40v, 50v, 60v, 70v, 80v, 90v