Data display
Card
Free7.2 KB gzippedA soft, rounded surface that groups related content. Compose it from Card.Media, Card.Header, Card.Title, Card.Description, Card.Body, and Card.Footer. For a fully clickable card, add one Card.LinkOverlay (or give Card.Title an href): the link stretches over the card while nested buttons stay independently clickable.
Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · Keys: Tab · Full report
Import
import { Card } from "@vjdesigns/vjdesigns-ui";
Importing only Card adds about 7.2 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.
Examples
Basic
Compose a card from its parts. Card.Header lays out a title, description and an action.
Team plan
Billed yearly · Renews Jan 1
12 of 20 seats in use. Add seats any time; you're only charged for the rest of the term.
import {
Button,
Card,
IconButton,
MoreHorizontalIcon,
Text,
} from "@vjdesigns/vjdesigns-ui";
export function Basic() {
return (
<Card style={{ width: "100%", maxWidth: "24rem" }}>
<Card.Header
title="Team plan"
description="Billed yearly · Renews Jan 1"
action={
<IconButton aria-label="Plan options" variant="ghost" tone="neutral" size="sm">
<MoreHorizontalIcon />
</IconButton>
}
/>
<Card.Body>
<Text tone="muted">12 of 20 seats in use. Add seats any time; you're only charged for the rest of the term.</Text>
</Card.Body>
<Card.Footer>
<Button variant="ghost" tone="neutral">
Manage
</Button>
<Button>Add seats</Button>
</Card.Footer>
</Card>
);
}
Variants
Elevated
A raised surface with a soft shadow. The default.
Outline
A flat surface with a border.
Filled
A sunken, recessed surface.
Soft
Tinted with a tone, with text that stays readable.
import { Card, Grid } from "@vjdesigns/vjdesigns-ui";
export function Variants() {
return (
<Grid columns={{ base: 1, sm: 2 }} gap={4} style={{ width: "100%" }}>
<Card variant="elevated">
<Card.Title>Elevated</Card.Title>
<Card.Description>A raised surface with a soft shadow. The default.</Card.Description>
</Card>
<Card variant="outline">
<Card.Title>Outline</Card.Title>
<Card.Description>A flat surface with a border.</Card.Description>
</Card>
<Card variant="filled">
<Card.Title>Filled</Card.Title>
<Card.Description>A sunken, recessed surface.</Card.Description>
</Card>
<Card variant="soft" tone="success">
<Card.Title>Soft</Card.Title>
<Card.Description>Tinted with a tone, with text that stays readable.</Card.Description>
</Card>
</Grid>
);
}
Clickable with media
Give Card.Title an href (or use Card.LinkOverlay) to make the whole card clickable. Buttons inside stay separately clickable. interactive adds the hover lift.
Sunset ridge trail
8.4 km · Moderate
import { Badge, Button, Card, Image } from "@vjdesigns/vjdesigns-ui";
export function ClickableWithMedia() {
return (
<Card interactive padding="md" style={{ width: "100%", maxWidth: "22rem" }}>
<Card.Media>
<Image src="/docs/mountains.svg" alt="Purple mountains at dusk under a low sun" />
</Card.Media>
<Card.Header
title={<Card.Title href="#example-clickable-with-media">Sunset ridge trail</Card.Title>}
description="8.4 km · Moderate"
action={<Badge tone="success">Open</Badge>}
/>
<Card.Footer justify="start">
<Button size="sm" variant="soft">
Save trail
</Button>
</Card.Footer>
</Card>
);
}
Horizontal
orientation="horizontal" puts media beside the content, and collapses to a column when the card is narrow.
Coastal weekend
Two nights · From $240
A quiet cabin a short walk from the beach, with bikes and kayaks included.
import { Card, Image, Text } from "@vjdesigns/vjdesigns-ui";
export function Horizontal() {
return (
<Card orientation="horizontal" variant="outline" style={{ width: "100%", maxWidth: "36rem" }}>
<Card.Media position="start" aspectRatio="1/1">
<Image src="/docs/coast.svg" alt="A sandy beach beside a calm blue sea" />
</Card.Media>
<Card.Header title="Coastal weekend" description="Two nights · From $240" />
<Card.Body>
<Text tone="muted" size="sm">
A quiet cabin a short walk from the beach, with bikes and kayaks included.
</Text>
</Card.Body>
</Card>
);
}
Accessibility
The whole card is clickable, but there's only one link: Card.LinkOverlay stretches the title's link over the card, so screen readers hear a single link named "Quarterly report" rather than a card full of nested links. level keeps the heading outline right.
Quarterly report
Revenue, churn and support volume for July to September.
import { Card } from "@vjdesigns/vjdesigns-ui";
export function Accessibility() {
return (
<Card variant="outline" padding="md" interactive style={{ width: "100%", maxWidth: "22rem" }}>
<Card.Title level={3} size="lg">
<Card.LinkOverlay href="#reports" onClick={(event) => event.preventDefault()}>
Quarterly report
</Card.LinkOverlay>
</Card.Title>
<Card.Description>Revenue, churn and support volume for July to September.</Card.Description>
</Card>
);
}
Translated
In Arabic the card mirrors: the header's action moves to the left and the footer's buttons line up from the right. The text is your own.
الفاتورة الشهرية
مستحقة في 1 نوفمبر
import { Badge, Button, Card, LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";
export function Translated() {
return (
<LocaleProvider locale="ar" messages={ar}>
<Card variant="outline" padding="lg" style={{ width: "100%", maxWidth: "24rem" }}>
<Card.Header
title="الفاتورة الشهرية"
description="مستحقة في 1 نوفمبر"
action={
<Badge tone="warning" variant="soft">
قيد الانتظار
</Badge>
}
/>
<Card.Footer justify="end">
<Button variant="outline" tone="neutral">
لاحقًا
</Button>
<Button>ادفع الآن</Button>
</Card.Footer>
</Card>
</LocaleProvider>
);
}
API reference
Card
| Prop | Type | Default |
|---|---|---|
asElement to render. | "article""section""div""li" | — |
variantSurface style. | "elevated""outline""filled""soft" | "elevated" |
toneSemantic color. Tints the | "neutral""primary""accent""success""warning""danger""info" | — |
radiusCorner rounding. | "none""xs""sm""md""lg""xl""2xl""pill" | "xl" |
paddingInner spacing (also sets the gap between parts). | "none""sm""md""lg" | "md" |
orientation
| "horizontal""vertical" | "vertical" |
interactiveHover lift (raise and stronger shadow). Use together with | boolean | false |
selectedShows the selected look: a primary ring plus a check badge (shape, not color alone). Purely visual: the selection semantics (e.g. a native radio or checkbox inside the card, or | boolean | false |
children | ReactNode | — |
Also accepts standard HTML attributes, plus className, style and ref.
Card.Header
Top row of a card: title and description on the start side, an optional action on the end side.
| Prop | Type | Default |
|---|---|---|
titleTitle. A string or number is wrapped in | ReactNode | — |
descriptionSupporting text under the title. A string or number is wrapped in | ReactNode | — |
actionSlot at the top-right (inline-end), e.g. an icon button or menu. Stays clickable above a stretched link. | ReactNode | — |
childrenExtra content in the text column, after the title and description (e.g. tags or meta). | ReactNode | — |
Also accepts native <div> attributes, plus className, style and ref.
Card.Title
Card heading in the display font. Its color follows the card (so it stays contrast-verified on soft cards). The first title in a card also names an article card via aria-labelledby.
| Prop | Type | Default |
|---|---|---|
levelHeading level, chosen by document outline (not looks). | 123456 | 3 |
sizeVisual size, independent of | "xs""sm""md""lg""xl""2xl""3xl""4xl""5xl""6xl" | "xl" |
hrefMakes the title a stretched link that covers the whole card (the card's single link, named by the title text). Shortcut for wrapping the text in | string | — |
Also accepts native <h3> attributes, plus className, style and ref.
Card.Description
Muted supporting text (tone-tinted on soft cards).
Also accepts standard HTML attributes, plus className, style and ref.
Card.Body
Main content area. Grows to fill the card so footers line up across a grid.
Also accepts standard HTML attributes, plus className, style and ref.
Card.Footer
Bottom row for actions. Buttons in it stay clickable above a stretched link.
| Prop | Type | Default |
|---|---|---|
justifyDistribution of actions. | "start""center""end""between""stretch" | "end" |
Also accepts native <div> attributes, plus className, style and ref.
Card.Media
Full-bleed media (image, video, illustration). Cancels the card's padding on its edges and follows the card's outer corner radius.
| Prop | Type | Default |
|---|---|---|
aspectRatioWidth-to-height ratio. Ignored beside the content in a horizontal card, where media fills the card's height. | "16/9""4/3""3/2""1/1""21/9""auto" | "16/9" |
positionWhich edge the media bleeds to. Defaults to | "top""bottom""start" | — |
childrenThe image, video, or other media. Direct | ReactNode | — |
Also accepts native <div> attributes, plus className, style and ref.
Card.LinkOverlay
Accessible "stretched link". Renders one real link (or button/label) whose ::after covers the whole card, so the card is clickable while there is a single focus stop with a meaningful name. Other links and buttons inside the card are lifted above it and stay independently clickable. Use at most one per card, and don't place it inside Card.Media.
| Prop | Type | Default |
|---|---|---|
as
| "a""button""label" | — |
childrenVisible text; it becomes the accessible name, so make it meaningful (usually the title). | ReactNode | — |
Also accepts standard HTML attributes, plus className, style and ref.
See what changed in each version in the Changelog.
Accessibility report
Card targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.
axe-core audit (live)
Checking the examples above…
Lighthouse audit
Light mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Dark mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.
Built-in behavior
Keyboard
| Key | Action |
|---|---|
| Tab | Moves to the card's link (Card.LinkOverlay) and its own buttons; the card itself isn't a tab stop. |
Roles and states
| Element | Role | States and properties |
|---|---|---|
| Card | article (with as="article") | aria-labelledby → Card.Title |
Card.LinkOverlay | link | Covers the card for pointer clicks; one tab stop |
Manual checks
Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.
| Check | What to test | WCAG 2.2 |
|---|---|---|
| Keyboard | Every action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck. | 2.1.1 (A), 2.1.2 (A) |
| Focus | Focus moves in a logical order, is always visible, and isn't hidden behind sticky headers. | 2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA) |
| Screen readers | Names, roles and states are announced correctly, and status changes are announced without moving focus. | 1.3.1 (A), 4.1.2 (A), 4.1.3 (AA) |
| Color | Meaning never depends on color alone; your own colors meet contrast in both modes. | 1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA) |
| Zoom and reflow | At 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed. | 1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA) |
| Pointer targets | Click and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap. | 2.5.8 (AA), 2.5.5 (AAA) |
| Motion | Animations respect the reduced-motion setting. | 2.3.3 (AAA) |