Skip to main content

Card

A bordered container for one item or group, with its title, content and actions.

In Dense data

See it live​

Start Storybook to see it live: npm run storybook

When to use it​

In Dense data: Dashboard figures.

  • 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:

  • Table: Records compared across rows.
  • Item: A compact row in a list.

How Dense data uses it​

A card on the page
Use A hairline border, no shadow
Not A shadow
On a busy grid, lines separate. Shadows blur the edges.

Words​

  • Lead with the object, then the state: "Alert 2041 contained."
  • Use numbers, not words for numbers.
  • One verb per button. No "please", no exclamation marks.
  • Use: Investigate, Filter, Assign, Escalated, Resolved. Avoid: Oops, Awesome, Please, Simply.

The labels components use, from the voice tokens:

  • content.action.commit: Save
  • content.action.cancel: Cancel
  • content.action.destroy: Delete
  • content.action.retry: Retry
  • content.action.empty-action: Change filters

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.

Changes with theme

Dense data 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.

PartIts token and the semantic it aliasesValue
Card
Fill
Changes with theme
component.card.backgroundcolor.surface.defaultvar(--card-background)Lightslate.light.0:#FFFFFFDarkslate.dark.50:#161B23
Border
Changes with theme
component.card.bordercolor.border.defaultvar(--card-border)Lightslate.light.200:#DDE2EADarkslate.dark.100:#262D38
Cornercomponent.card.radiusradius.containervar(--card-radius)radius.4:0.25rem
Paddingcomponent.card.paddingspace.inset.containervar(--card-padding)space.16:1rem
Shadowcomponent.card.shadowelevation.cardvar(--card-shadow)shadow.none
Gapcomponent.card.gapspace.gap.defaultvar(--card-gap)space.8:0.5rem
Text
Changes with theme
component.card.labelcolor.text.primaryvar(--card-label)Lightslate.light.900:#161B23Darkslate.dark.900:#F7F8FA
Border widthcomponent.card.border-widthborder-width.defaultvar(--card-border-width)border-width.1:1px
Header
Gapcomponent.card.header.gapspace.gap.tightvar(--card-header-gap)space.4:0.25rem
Title
Font familycomponent.card.title.font-familytype.heading.font-familyvar(--card-title-font-family)font.family.ibm-plex-sans:"IBM Plex Sans", system-ui, sans-serif
Text sizecomponent.card.title.font-sizetype.heading.font-sizevar(--card-title-font-size)font.size.16:1rem
Weightcomponent.card.title.font-weighttype.heading.font-weightvar(--card-title-font-weight)font.weight.600:600
Line heightcomponent.card.title.line-heighttype.heading.line-heightvar(--card-title-line-height)font.line-height.1_2:1.2
Description
Text
Changes with theme
component.card.description.labelcolor.text.secondaryvar(--card-description-label)Lightslate.light.700:#3D4655Darkslate.dark.500:#C4CBD6
Text sizecomponent.card.description.font-sizetype.body.font-sizevar(--card-description-font-size)font.size.14:0.875rem
Content
Gapcomponent.card.content.gapspace.gap.defaultvar(--card-content-gap)space.8:0.5rem
Footer
Gapcomponent.card.footer.gapspace.gap.defaultvar(--card-footer-gap)space.8:0.5rem