Components
Card
Cards contain content and actions about a single subject.
About the card component
A card is often a subset or summary of a larger idea. It acts as an entry point to more detailed information. This summary can contain a variety of content types, such as text, images and multimedia, or buttons and links.
An individual card is typically a member of a collection of similar cards, not a single card in isolation. A card is distinguished from others in its collection by its content, and cards are distinguished from the broader page context in form — usually with a border or a shadow.
Finally, a card is modular, which means you can vary the order of cards in a collection without destroying any individual card’s meaning.
Default card
-
Card
Lorem ipsum dolor sit amet consectetur adipisicing elit. Facilis earum tenetur quo cupiditate, eaque qui officia recusandae.
-
Card with Media
Lorem ipsum dolor sit amet consectetur adipisicing elit. Facilis earum tenetur quo cupiditate, eaque qui officia recusandae.
-
Media with header first
Lorem ipsum dolor sit amet consectetur adipisicing elit. Tempore possimus similique nemo odit doloremque laudantium?
-
Inset media
Etiam vitae sodales metus. Fusce id orci dignissim, efficitur risus eget, tempus odio. Donec lectus ante, auctor eget cursus sed, convallis quis magna. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Mauris mattis tellus bibendum aliquet malesuada.
-
Exdent media
Lorem ipsum dolor sit amet consectetur adipisicing elit. Tempore possimus similique nemo odit doloremque laudantium?
Flag layout card
-
Default flag
Lorem ipsum dolor sit amet consectetur adipisicing elit.
-
Flag media right inset
Lorem ipsum dolor sit amet consectetur adipisicing elit.
Guidance
When to use the card component
- Collections of related content. Cards help present a collection of related groups of content, like articles or sections of a website.
When to consider something else
- Tabular data. Don’t use a card as a substitute for a table row.
- Simple calls to action. Use a button instead.
- Standalone content. Consider an
aside
or another standalone element. - Sequential, continuous text. Cards should be self-contained and modular. If the reader is meant to read from card to card, consider a list or simple body text and headings.
Usability guidance
- Make cards actionable. Since cards are used as a summary of more detailed information, any individual card should link out to that information.
- Don’t use the card component only for decoration. Use the card component for cards, not for any type of content that’s designed to have a border around it.
- Include non-redundant content. Don’t repeat images or content common to all or most cards in a collection. Repeated information (like using the same image for each card in a collection) makes it more difficult to distinguish cards from one another.
- Make sure images are properly sized. Cards often change size depending on the device. Make sure you use an image that works well on any device at any size.
- Use simple styling. Avoid distracting skeumorphism. Don’t include any card styling that calls too much attention to the metaphor of a paper card, like folds, bent edges, or paper texture.
Accessibility guidance
- Use unordered lists and list items. Use a
ul
for a card group and anli
for each card. This formatting allows screen readers to enumerate the items in the card group and allows shortcuts between list items. - Use the appropriate heading level for your page. Update heading level based on the content of your page to make sure card headings are in the correct, logical outline order.
- Use CSS to order the media element. Logically, the media element should follow the header element. Don’t re-organize the markup to reverse their order.
Using the card component
-
Control card size and layout with USWDS utilities. The card component works well with layout grid utilities. The
usa-card-group
block is functionally a wrap-ablegrid-row
, and each individualusa-card
is agrid-col
. This means you can use a grid utility liketablet:grid-col-4
to set a four-column size on a card attablet
width. You can also set custom grid gaps on ausa-card-group
usinggrid-gap
utilities.Since the Design System grid is based on flexbox, you can use flex positioning utilities on the card group. The default alignment is stretch (stretch aligns the top and bottom of each card in a row), but the
flex-align-start
utility can set the alignment to the top of the row. - Control image aspect ratio with the
add-aspect
utility. Add aspect ratio utility classes tousa-card__img
orusa-card__media
elements to control the aspect ratio on card images. Alternatively, control aspect ratio in your Sass files via theadd-aspect
mixin. - Style cards with utilities. Style the
usa-card__container
element with utilities to achieve custom effects, such as changing the border or background color or adding a drop shadow.
Card settings
Variable | Description |
---|---|
$theme-card-border-color
|
Stroke color of card. |
$theme-card-border-radius
|
Border radius of card. |
$theme-card-border-width
|
Stroke thickness of card. |
$theme-card-gap
|
Gap between cards in a card group. |
$theme-card-flag-min-width
|
Width at which flag cards change to horizontal layout. |
$theme-card-flag-image-width
|
Fixed image width in the card flag variant. |
$theme-card-font-family
|
Font family for card body. |
$theme-card-header-typeset
|
Family, size, and line height of the heading. |
$theme-card-margin-bottom
|
Bottom margin for card. |
$theme-card-padding-perimeter
|
Padding between card elements and card border. |
$theme-card-padding-y
|
Vertical padding between card elements. |
Card variants
Variant | Description |
---|---|
|
Display in a horizontal (“flag”) orientation at a specified width ( |
|
Displays the header element before the media element. |
|
In combination with |
|
Indents the media element so it doesn’t extend to the edge of the card. |
|
Extends the body element out over the card border. Useful for light-bordered cards. |
|
Extends the footer element out over the card border. Useful for light-bordered cards. |
|
Extends the header element out over the card border. Useful for light-bordered cards. |
|
Extends the media element out over the card border. Useful for light-bordered cards. |
Package
-
Package usage:
@forward "usa-card";
- Dependencies:
uswds-fonts
Latest updates
Meaningful code and guidance updates are listed in the following table:
Date | USWDS version | Affects | Description |
---|---|---|---|
2024-10-04 | 3.9.0 |
|
Breaking
Fixed a bug that caused the component to ignore the |
2023-11-30 | N/A |
|
Updated the grid breakpoints in the card template. This change affects only the template grid, not the component itself. More information: uswds-site#2299 |
2023-11-20 | N/A |
|
Clarified guidance for using layout grid utilities. More information: uswds-site#2149 |
2023-11-09 | 3.7.0 |
|
Fixed a bug that prevented |
2023-09-29 | 3.6.1 |
|
Fixed a margin bug on header-first variants that caused exdent card media to overlap headers. More information: uswds#5423 |
2023-09-20 | N/A |
|
Added |
2023-08-23 | 3.6.0 |
|
Fixed a bug that prevented |
2023-06-09 | 3.5.0 |
|
Replaced |
2022-08-29 | N/A |
|
Added guidance for using aspect ratio utility classes. More information: uswds-site#1729 |
2022-08-05 | 3.1.0 |
|
Added |
2022-04-28 | 3.0.0 |
|
Breaking Updated to Sass module syntax and new package structure. More information: uswds#4656 |
2021-06-16 | 2.12.0 |
|
Updated the exdent modifier to work as documented.
Now adding the |
2021-03-17 | N/A |
|
Updated and improved guidance around cards. More information: uswds-site#1180 |