Utilities
Text styles
Change the appearance of text. (Not all text styles are available in every typeface.)
CSS properties
.text-italic
.text-no-italic
.text-thin
.text-light
.text-normal
.text-medium (Note: not included in default set)
.text-semibold
.text-bold
.text-heavy
.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.025em
.text-ls-2 0.1em
.text-ls-3 0.15em
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-underline
.text-strike
.text-no-strike
.text-no-underline
gray-5
#f0f0f0
gray-cool-10
#dfe1e2
gray-cool-30
#a9aeb1
gray-cool-50
#71767a
gray-cool-60
#565c65
gray-cool-70
#3d4551
gray-90
#1b1b1b
gray-90
#1b1b1b
blue-10
#d9e8f6
blue-30
#73b3e7
blue-60v
#005ea2
blue-warm-60v
#0050d8
blue-warm-70v
#1a4480
blue-warm-80v
#162e51
red-cool-10v
#f8dfe2
red-30
#f2938c
red-50
#d83933
red-cool-50v
#e41d3d
red-60v
#b50909
red-70v
#8b0a03
blue-cool-5v
#e1f3f8
blue-cool-20v
#97d4ea
cyan-30v
#00bde3
blue-cool-40v
#28a0cb
blue-cool-60v
#07648d
orange-10
#f2e4d4
orange-20v
#ffbc78
orange-30v
#fa9441
orange-50v
#c05600
orange-60
#775540
red-warm-60v
#9c3d10
red-warm-80
#332d29
.text-uppercase
.text-lowercase
.text-no-uppercase
.text-no-lowercase
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
.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.
style
style
)weight
weight
)value
value
'')tabular
tabular
')decoration
decoration
')color
color
)case
case
)vertical-align
vertical-align
)white-space
white-space
)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 (likeneg-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')
oru-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.
Example
.tablet:padding-y-2
Output
@media screen and (min-width: 640px) { .tablet\:padding-y-2 { padding-top: 1rem; padding-bottom: 1rem; } }
Set up which breakpoints are available to USWDS utilities by setting the $theme-utility-breakpoints
variable in your USWDS settings configuration.
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 your USWDS settings configuration. When modifying settings stored as a map, undefined map elements will keep their default values.
Example
@use "uswds-core" with ( $background-color-settings: ( responsive: true ) );
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.
Example
.hover:bg-primary-vivid
Output
.hover\:bg-primary-vivid:hover { background-color: #0052de; }
Set whether a utility outputs a specific state variant by setting the value of the $[utility_family]-settings.[state]
variable in your USWDS settings configuration. When modifying settings stored as a map, undefined map elements will keep their default values.
Example
@use "uswds-core" with ( $background-color-settings: ( active: true ) );
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 in your USWDS settings configuration.
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 standard output table. Customize and refine any utility family’s specific values by editing the $[utility_family]-manual-values
and $[utility_family]-palettes
variables in your USWDS settings configuration.
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.
Example
$width-manual-values: ( 'tab': 4ch, );
Output
.width-tab { width: 4ch; }
Palettes
Palettes are predefined groups of values. Add palettes to the $[utility_family]-palettes
list variable in your USWDS settings configuration 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 |
Latest updates
Meaningful code and guidance updates are listed in the following table:
Date | USWDS version | Affects | Description |
---|---|---|---|
2021-05-25 | N/A |
|
Corrected the value of |