Card
A bordered container for one item or group, with its title, content and actions.
In Accessible first
See it live
npm run storybookWhen to use it
In Accessible first: Groups a summary before submitting.
- Use it when: A repeating unit of title, media and one destination or action.
- Not when: Records people compare cell by cell (a table), or a whole card as one big link that screen readers read as one.
Instead:
How Accessible first uses it
Words
- Use common words. Explain any term you must use.
- One idea per sentence. Put the action first.
- Never blame the person.
- Use: Continue, Change, Start, You. Avoid: Invalid, Utilise, Submit, Error code.
The labels components use, from the voice tokens:
content.action.commit: Continuecontent.action.cancel: Go backcontent.action.destroy: Deletecontent.action.retry: Try againcontent.action.empty-action: Start a new application
See Voice and tone for the whole voice.
Accessibility and keyboard
Test before you ship:
- One inner link or button names the destination; the rest is not one big link. undefined
Use it in code
npx open-ds add card
The component reads only component keys and semantic tokens, so it follows the brand and mode on <html>.
Tokens it reads
Card reads 17 tokens of its own, each an alias of a semantic token. Each row is one part: its own token, the semantic it aliases, and the value it ends at. Change a semantic and every component that reads it follows; override one of Card's tokens to change Card alone.
Accessible first decides what changes when you switch theme. Here a switch changes colors only, so the marked rows differ between light and dark; everything else holds steady.
| Part | Its token and the semantic it aliases | Value |
|---|---|---|
| Card | ||
| Fill Changes with theme | component.card.backgroundcolor.surface.defaultvar(--card-background) | Lightgray.light.0:#FFFFFFDarkgray.dark.50:#141414 |
| Border Changes with theme | component.card.bordercolor.border.defaultvar(--card-border) | Lightgray.light.200:#D6D6D6Darkgray.dark.100:#222222 |
| Corner | component.card.radiusradius.containervar(--card-radius) | radius.8:0.5rem |
| Padding | component.card.paddingspace.inset.containervar(--card-padding) | space.24:1.5rem |
| Shadow | component.card.shadowelevation.cardvar(--card-shadow) | shadow.none |
| Gap | component.card.gapspace.gap.defaultvar(--card-gap) | space.16:1rem |
| Text Changes with theme | component.card.labelcolor.text.primaryvar(--card-label) | Lightgray.light.900:#141414Darkgray.dark.900:#F7F7F7 |
| Border width | component.card.border-widthborder-width.defaultvar(--card-border-width) | border-width.2:2px |
| Header | ||
| Gap | component.card.header.gapspace.gap.tightvar(--card-header-gap) | space.12:0.75rem |
| Title | ||
| Font family | component.card.title.font-familytype.heading.font-familyvar(--card-title-font-family) | font.family.atkinson-hyperlegible:"Atkinson Hyperlegible", Verdana, sans-serif |
| Text size | component.card.title.font-sizetype.heading.font-sizevar(--card-title-font-size) | font.size.22:1.375rem |
| Weight | component.card.title.font-weighttype.heading.font-weightvar(--card-title-font-weight) | font.weight.700:700 |
| Line height | component.card.title.line-heighttype.heading.line-heightvar(--card-title-line-height) | font.line-height.1_25:1.25 |
| Description | ||
| Text Changes with theme | component.card.description.labelcolor.text.secondaryvar(--card-description-label) | Lightgray.light.700:#333333Darkgray.dark.600:#B4B4B4 |
| Text size | component.card.description.font-sizetype.body.font-sizevar(--card-description-font-size) | font.size.19:1.1875rem |
| Content | ||
| Gap | component.card.content.gapspace.gap.defaultvar(--card-content-gap) | space.16:1rem |
| Footer | ||
| Gap | component.card.footer.gapspace.gap.defaultvar(--card-footer-gap) | space.16:1rem |