Card
A bordered, rounded content surface with header / title / description / action / content / footer parts. The surface, radius and border come from `Box`; the card owns only its column layout, its padding and its shadow.
Preview
Rendered from the story the storybook (a11y) CI gate runs axe against — the preview can't show something that hasn't been verified.
Install
Two equivalent paths — the URL works in any shadcn-CLI setup; the alias works once you've registered @interlace in your components.json.
npx shadcn@latest add https://ds.interlace.tools/r/card.jsonnpx shadcn@latest add @interlace/cardBehavior
What this component does — the keyboard path, the measured colour, the text equivalent and the states it can be in. Every figure below is read out of the test or the source that enforces it by scripts/build-behavior-map.mjs, so nothing here can outlive the gate that keeps it true.
Measured contrast
packages/ui/__tests__/theme-contract-lock.test.ts ↗Every semantic colour pair this component's own source uses, measured against the shipped hexes in all 4 theme × scheme combinations. The tightest is muted-foreground on background at 7.82:1 (harbor · light), against a floor of 4.5:1.
| Pair | interlacelight | interlacedark | harborlight | harbordark | Floor |
|---|---|---|---|---|---|
| muted-foreground on backgroundsecondary copy | 9.11:1 | 11.16:1 | 7.82:1 | 9.52:1 | 4.5:1SC 1.4.3 |
| muted-foreground on cardsecondary copy in a card | 9.41:1 | 10.48:1 | 8.25:1 | 8.64:1 | 4.5:1SC 1.4.3 |
| ring on backgroundfocus ring (SC 2.4.13) | 8.52:1 | 11.63:1 | 8.39:1 | 10.03:1 | 3.0:1SC 1.4.11 |
| ring on cardfocus ring inside a card | 8.80:1 | 10.92:1 | 8.86:1 | 9.10:1 | 3.0:1SC 1.4.11 |
| foreground on backgroundbody copy | 19.02:1 | 16.73:1 | 17.74:1 | 16.19:1 | 4.5:1SC 1.4.3 |
Text pairs are held to 4.5:1 (WCAG 2.2 SC 1.4.3); borders, rings and chart axes to 3:1 (SC 1.4.11 non-text). Bold is the worst cell in the row — the one a brand fork has to keep an eye on.
Runtime contract
packages/ui/vitest.config.ts ↗Where it renders, how narrow it survives, and whether its lines are inside the coverage gate — three answers a consumer needs before the paste, not after the bug.
- Render boundary
server componentRenders during SSR / RSC with no hydration cost. It can be imported from a server component without pulling the page into the client.
- Minimum viewport
none declaredNo width floor: it takes the width it is given. Its container owns the layout question.
- Coverage gate
not in the gateThe 100% gate currently covers
src/charts/**/*.{ts,tsx}andpure cores: day keys, puzzle order, streak arithmetic.and,and, // DataTable: sort order, blanks last, page window, selection.and, // Photo upload: what a file is, what it says about its owner, the plan, the reducer.and, // The account control: names and initials, the return-path check, the reducer, the hook, the menu.and,and,and, // The five pure variant/model modules.and, // Booking: the slot pickerandsrc/patterns/time-slot-model.tsandsrc/patterns/share-image-model.tsandsrc/patterns/{interest-model,commitment-model,session-plan-model,recap-model}.tsandsrc/primitives/{file-model.ts,file-drop.tsx}andsrc/patterns/avatar-upload.tsxands first steps.and, // The 37 components with real render coverage. See the ledger above.and, // Patterns with full render coverage — the same ledger rule: a // file is in at 100 or it is out, and joining is a one-line diff.and, // Effects with full render coverage, on the same rule.and,. This file is outside it — the glob widens in phase 7.2.
History
This component is at v2.4.1, first shipped in @interlace/ui 1.0.0. The version is stamped as a banner into the file the install writes, so the copy in your tree says which one you have — compare it with the number above before deciding whether to re-run the install.
@interlace/ui 2.3.01 entry
- Changedpatch
Keyboard focus now shows in forced colours mode (Windows Contrast themes). Controls drew their focus ring as a box-shadow and removed the outline with
outline-none, which in Tailwind v4 removes it in every mode; forced colours drops box-shadows, so a focused control showed nothing (WCAG 2.4.7). They now usefocus-visible:outline-hidden: the same in a normal page, a 2px system-colour outline on keyboard focus in forced colours.forced-colors-focus-lockkeepsoutline-noneout.Components- @interlace/chart-frame
- @interlace/choropleth-map
- @interlace/dot-plot
- @interlace/seat-chart
- @interlace/share-chart
- @interlace/breakout-room
- @interlace/pair-talk
- @interlace/round-summary
- @interlace/team-board
- @interlace/article-card
- @interlace/carousel
- @interlace/dialogue-stepper
- @interlace/dialogue
- @interlace/focus-grid
- @interlace/multi-step-form
- @interlace/photo-upload-crop
- @interlace/prev-next-post
- @interlace/time-slot-picker
- @interlace/accordion
- @interlace/button
- @interlace/button-variants
- @interlace/toolbar
- @interlace/calendar
- @interlace/checkbox
- @interlace/choice-card
- @interlace/code-block
- @interlace/code-editor
- @interlace/collapsible
- @interlace/combobox
- @interlace/command-palette
- @interlace/drawer
- @interlace/focus-ring
- @interlace/input
- @interlace/number-field
- @interlace/otp-field
- @interlace/prose
- @interlace/radio-group
- @interlace/reading-settings
- @interlace/scroll-area
- @interlace/select
- @interlace/skip-link
- @interlace/slider
- @interlace/switch
- @interlace/tabs
- @interlace/tag
- @interlace/textarea
- @interlace/theme-switcher
- @interlace/toast
- @interlace/toc
- @interlace/toggle
- @interlace/wordmark
- @interlace/account-menu
@interlace/ui 2.0.05 entries
- Breakingmajor
The last borrowed motion components are replaced with Interlace's own, written from scratch. Content that moves now renders in full on the server and is announced once; decoration is a layer you drop inside any component, so a button stays a
Buttonand a card stays aCard: -CountUp: a number that counts to its value when it scrolls into view. The server renders the final figure, the box never shifts, andformattakes anyIntl.NumberFormatoptions. -Scroller: a looping row of items. Each item is announced and tabbed to once, a visible Pause button sits beside it, and under reduced motion it becomes a plain scrollable row. -StaggerList: a realulorolwhose items arrive one by one, once. Focus shows an item at once. -SheenText: a few words painted with a slow travelling gradient, on text-grade tokens, with a forced-colours fallback. -Sheen: a band of light that crosses its parent. Put it inside aButton; it sits under the label. -EdgeGlow: a light that runs around the edge of aCardor any positioned element. -GridField: graph-paper lines or a dot grid, with a few seeded (or chosen) cells that light up and fade, and withinteractive, the cell under the pointer.Buttonis nowrelative isolateandCardisrelative, soSheenandEdgeGlowwork inside them with no extra classes.Components- @interlace/count-up
- @interlace/scroller
- @interlace/stagger-list
- @interlace/sheen-text
- @interlace/sheen
- @interlace/edge-glow
- @interlace/grid-field
- @interlace/button
- @interlace/number-ticker
- @interlace/marquee
- @interlace/animated-list
- @interlace/animated-gradient-text
- @interlace/shimmer-button
- @interlace/border-beam
- @interlace/animated-grid-pattern
- @interlace/interactive-grid-pattern
- @interlace/grid-pattern
- @interlace/dot-pattern
- @interlace/particles
- Addedminor
The editorial look is one line:
@theme { --font-heading: var(--font-serif); }gives serif headings over the sans body.CardTitlenow readsfont-headinglike every other heading in the kit, so card titles follow too; with the default--font-heading(your body face) nothing changes.interlace-foundationnames a serif stack (Source Serif 4, then the system serifs) for--font-serif. A new Storybook story, Foundations/Typography/Editorial Headings, shows it. - Addedminor
Comfortable density reaches the small links, and Card gets a whole-card link. Under
data-density="comfortable", Tag and Breadcrumb links keep their size but take the tap through an invisible pad of--spacing-target(44px), the ClaimCard section summary and Footer links grow to 44px rows, and the default density stays at the same rhythm. NewCardLink: wrap the card's title text in it and the whole card becomes the target through a stretched::after, with one accessible name, the focus ring on the card and a quiet border lift on hover.asChildtakes a router link. - Addedminor
Interlace has one named z-index scale.
interlace-baseadds--z-index-*steps, soz-backdrop,z-base,z-raised,z-sticky,z-header,z-indicator,z-overlay,z-modal,z-popover,z-toast,z-tooltipandz-skip-linkare utilities, and an app retunes the order with--z-index-*on:root. Every component now uses a name instead of a number. Topbar, AppHeader and TabBar sit onz-header, above anything inside the page: before, they werez-10like a Section overlap band, ScrollStory steps and a Dialogue speaker, which tied and painted over the sticky header while scrolling. ScrollStory and Dialogue isolate their own layers. Popover and Tooltip set their layer on the positioner, so it reaches the page, and a select or menu inside a dialog opens above it. Numericz-10and friends still work in your app. Decorative backdrops (Sheen, GradientMesh, GridField, SkyBackdrop, CtaSection and FocusGrid media, the TopbarNav pill) move from-z-10toz-backdrop(-1): if you placed your own layer between -10 and -1 behind one of them, it now paints below the backdrop.Components- @interlace/interlace-base
- @interlace/topbar
- @interlace/app-header
- @interlace/tab-bar
- @interlace/section
- @interlace/scroll-story
- @interlace/dialogue
- @interlace/reading-layout
- @interlace/article-card
- @interlace/timeline
- @interlace/timeline-map
- @interlace/topbar-nav
- @interlace/pull-to-refresh
- @interlace/cta-section
- @interlace/focus-grid
- @interlace/hero-cosmic
- @interlace/sheen
- @interlace/pointer-surface
- @interlace/sky-backdrop
- @interlace/grid-field
- @interlace/gradient-mesh
- @interlace/tooltip
- @interlace/drawer
- @interlace/dropdown-menu
- @interlace/toast
- @interlace/dialog
- @interlace/alert-dialog
- @interlace/combobox
- @interlace/sheet
- @interlace/popover
- @interlace/context-menu
- @interlace/select
- @interlace/reading-strand
- @interlace/skip-link
- @interlace/order-game
- Changedpatch
fix(ui): A loading Card or Badge keeps its
data-testidand ARIA. Theloadingbranch rendered a Skeleton with onlyclassName, so an E2E selector or anaria-labelvanished for exactly as long as the content was loading. Card forwards all its props; Badge forwardsdata-*,aria-*andid(the rest are<span>props and the skeleton is a<div>).Components
@interlace/ui 1.0.01 entry
- Addedminor
The component floor reaches every tier: form, overlay, navigation and display primitives were modelled to the portable 26-rule floor with skeletons, locked breakpoints, and AA contrast measured per composite rather than eyeballed.
Components- @interlace/input
- @interlace/textarea
- @interlace/select
- @interlace/checkbox
- @interlace/radio-group
- @interlace/switch
- @interlace/slider
- @interlace/number-field
- @interlace/form
- @interlace/label
- @interlace/dialog
- @interlace/alert-dialog
- @interlace/sheet
- @interlace/popover
- @interlace/tooltip
- @interlace/hover-card
- @interlace/dropdown-menu
- @interlace/context-menu
- @interlace/tabs
- @interlace/accordion
- @interlace/collapsible
- @interlace/breadcrumb
- @interlace/pagination
- @interlace/toast
- @interlace/badge
- @interlace/avatar
- @interlace/alert
- @interlace/separator
- @interlace/progress
- @interlace/skeleton
Import
8 named exports — pull the parts you need.
import { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardLink, CardTitle } from '@/components/ui/card';Anatomy
Extracted from the primitive's JSDoc header. The source is the only documentation that can't drift.
Card (Box — surface=card, radius=lg, border, flex-col gap-6 py-6)
├─ CardHeader (grid — @container/card-header, px-6)
│ ├─ CardTitle
│ ├─ CardDescription
│ └─ CardAction (col 2, spans both header rows)
├─ CardContent (px-6)
└─ CardFooter (flex, px-6)
CardLink (a — anywhere inside, usually in the title)API reference
Parsed from the type declarations in the source — the same file the install writes into your tree, so this table can't drift from the component you get.
CardProps
Also accepts every <div> attribute.
| Prop | Type | Description |
|---|---|---|
| loading | boolean | When true, render a `<Skeleton variant="card" />` composite (title + body lines silhouette) instead of the normal Card surface. The skeleton shape-matches the card footprint so a card grid doesn't shift when real data arrives. |
CardLinkProps
Also accepts every <a> attribute.
| Prop | Type | Description |
|---|---|---|
| asChild | boolean | Merge onto the single child element (a router link) instead of rendering an `<a>`. |
Skeleton
Pass loading and the component renders a shape-matched <Skeleton /> in its own place — same box, so nothing reflows when the data lands. Below is the same story with loading={true}.
<Card loading={isPending} />Accessibility
Every story for this component is rendered headlessly and checked with axe-core (wcag2aa, wcag22aa, best-practice, ACT) on every PR. That gate has no continue-on-error, so what ships has zero known violations.
What follows is what static analysis can see. Axe cannot press a key and never sees an overlay open, so the operable-without-a-mouse claim lives in Behavior instead, where the keyboard path is replayed step by step.
- Focus + keyboard behaviour
- Native element semantics — no interaction layer to get wrong.
- Focus ring (WCAG 2.2 SC 2.4.13)
- Drawn by the component's own focus-visible classes, so it holds with or without the opt-in preflight.
- Reduced motion
- No animation to gate.
- ARIA in the source
- None — semantics come from the element or the Base UI primitive rather than hand-written ARIA.
Examples
2 more states from the same story file.
R-rule compliance
Every primitive in @interlace/ui models to the portable 26-rule floor enforced by the componentApi ESLint preset. The cells below pin exactly where each rule applies in this file.
| Rule | Concept | Where |
|---|---|---|
| R4 | Extends native el | `React.ComponentProps<'div'>` on every part |
| R6 | data-slot per part | card / -header / -title / -description / -action / -content / -footer / -link |
| R7 | cn + ...rest | `cn('px-6', className)` + `{...props}` on each part |
| R10 | Composition seam | header layout keys off the `card-action` slot, not a prop |
| R12 | Reuse over wrap | `Box` owns surface + radius + border; `Skeleton` owns loading |
| R19 | Tokens only | `surface="card"`, `text-muted-foreground` |
| R25 | Server component | No hooks → no `'use client'` |
Dependencies
- Base UI primitive
- Native / no Base UI dependency
- Lucide icons
- none
- NPM dependencies
- none
- Registry dependencies
Source
The full implementation — components/ui/card.tsx once installed.
import * as React from 'react';
// @interlace/card v2.4.1 — Interlace design system.
// Docs, props and live preview: https://ds.interlace.tools/c/card
// What changed since: https://ds.interlace.tools/c/card#history
// Generated banner — keep it, the upgrade diff reads this version.
/**
* @interlace/ui — Card
*
* A bordered, rounded content surface with header / title / description /
* action / content / footer parts. The surface, radius and border come from
* `Box`; the card owns only its column layout, its padding and its shadow.
*
* A `loading` card renders the shape-matched `Skeleton variant="card"`
* instead, so a card grid does not shift when the data lands.
*
* ## Anatomy
*
* Card (Box — surface=card, radius=lg, border, flex-col gap-6 py-6)
…198 more lines…Registry JSON
The raw registry record — what the shadcn CLI fetches.