Card
A surface that groups related content, with Card.Header, Card.Preview, Card.Body and Card.Footer.
**Selectable cards** (onSelect) come in two patterns:
- A card without interactive content is itself the control (selectionControl="card", the default): it is a role="button" tab stop activated by click, Enter (key down) or Space (key up, cancelled by moving focus away first), with aria-pressed reflecting selected. Its content becomes the button's name, so headings and other structure inside it are flattened.
- A card that contains buttons or links, or headings that must stay navigable, uses selectionControl="checkbox": a built-in checkbox named by the header title carries the selection, and the card's actions and structure stay separate from it.
In both modes events that start inside a nested interactive element, or in content portaled out of the card, are ignored. onClick, onKeyDown and onKeyUp are composed with the built-in selection (call event.preventDefault() to skip it). A selected card without onSelect shows the selected look only; its state is not exposed to assistive technology.
React Server Components cannot dot into a client module: import the flat names CardHeader, CardPreview, CardBody and CardFooter there; Card.Header etc. work in client files.
Examples
Default
This is the card body content.
export const Default: Story = {
render: (args) => (
<Card {...args}>
<Card.Header title="Card Title" />
<Card.Body>
<p>This is the card body content.</p>
</Card.Body>
</Card>
),
};With Header Subtitle
All tasks are on track for the upcoming release.
export const WithHeaderSubtitle: Story = {
render: (args) => (
<Card {...args}>
<Card.Header title="Project Status" subtitle="Last updated 2 hours ago" />
<Card.Body>
<p>All tasks are on track for the upcoming release.</p>
</Card.Body>
</Card>
),
};Selected
This card starts selected. Press Enter or Space to toggle it.
export const Selected: Story = {
args: {
onSelect: fn(),
},
render: function SelectedCard(args) {
const [selected, setSelected] = React.useState(true);
const toggle = () => {
setSelected((value) => !value);
args.onSelect?.();
};
return (
<Card selected={selected} {...args} onSelect={toggle}>
<Card.Header title="Selected Card" />
<Card.Body>
<p>This card starts selected. Press Enter or Space to toggle it.</p>
</Card.Body>
</Card>
);
},
};Clickable
Unlimited projects and priority support.
export const Clickable: Story = {
args: {
onSelect: fn(),
},
render: function ClickableCard(args) {
const [selected, setSelected] = React.useState(false);
const toggle = () => {
setSelected((value) => !value);
args.onSelect?.();
};
return (
<Card selected={selected} {...args} onSelect={toggle}>
<Card.Header title="Pro plan" subtitle="Press Enter or Space to select" />
<Card.Body>
<p>Unlimited projects and priority support.</p>
</Card.Body>
</Card>
);
},
};Selectable With Actions
Shared workspaces for up to 20 people.
export const SelectableWithActions: Story = {
args: {
onSelect: fn(),
selectionControl: 'checkbox',
},
render: function SelectableCard(args) {
const [selected, setSelected] = React.useState(false);
const toggle = () => {
setSelected((value) => !value);
args.onSelect?.();
};
return (
<Card selected={selected} {...args} onSelect={toggle}>
<Card.Header title="Team plan" subtitle="Click the card or the checkbox" />
<Card.Body>
<p>Shared workspaces for up to 20 people.</p>
</Card.Body>
<Card.Footer>
<Button appearance="subtle">Compare plans</Button>
</Card.Footer>
</Card>
);
},
};Full Composition
Body content with details about this card item.
export const FullComposition: Story = {
render: (args) => (
<Card {...args}>
<Card.Header title="Full Card" subtitle="With all sections" />
<Card.Body>
<p>Body content with details about this card item.</p>
</Card.Body>
<Card.Footer>
<Button>Cancel</Button>
<Button appearance="primary">Confirm</Button>
</Card.Footer>
</Card>
),
};Appearances And Sizes
export const AppearancesAndSizes: Story = {
render: (args) => (
<div className="flex flex-col gap-4">
<div className="flex flex-wrap gap-4">
{(['filled', 'filled-alternative', 'outline', 'subtle'] as const).map((appearance) => (
<Card key={appearance} {...args} appearance={appearance}>
<Card.Header title={appearance} subtitle="appearance" />
<Card.Body>Body</Card.Body>
</Card>
))}
</div>
<div className="flex flex-wrap gap-4">
{(['small', 'medium', 'large'] as const).map((size) => (
<Card key={size} {...args} size={size} appearance="outline">
<Card.Header title={size} subtitle="size" />
<Card.Body>Body</Card.Body>
</Card>
))}
</div>
</div>
),
};Horizontal With Preview
export const HorizontalWithPreview: Story = {
args: { style: { width: 480 } },
render: (args) => (
<Card {...args} orientation="horizontal" appearance="outline">
<Card.Preview logo={<span className="text-wave-caption-1">W</span>}>
<div className="flex h-32 w-40 items-center justify-center bg-wave-muted text-wave-foreground">
Preview
</div>
</Card.Preview>
<div>
<Card.Header title="Quarterly report" subtitle="Updated today" />
<Card.Body>Highlights from the last three months.</Card.Body>
</div>
</Card>
),
};Header With Image And Action
export const HeaderWithImageAndAction: Story = {
render: (args) => (
<Card {...args} appearance="outline">
<Card.Header
title="Design review"
subtitle="Thursday, 10:00"
image={<Avatar name="Ada Lovelace" />}
action={
<Button appearance="subtle" aria-label="More options">
…
</Button>
}
/>
<Card.Body>Agenda and notes.</Card.Body>
</Card>
),
};Floating Action With Checkbox
export const FloatingActionWithCheckbox: Story = {
args: { onSelect: fn(), selectionControl: 'checkbox' },
render: function FloatingAction(args) {
const [selected, setSelected] = React.useState(false);
return (
<Card
{...args}
selected={selected}
onSelect={() => setSelected((value) => !value)}
floatingAction={
<Button appearance="subtle" aria-label="More options">
…
</Button>
}
appearance="outline"
>
<Card.Header title="Team plan" />
<Card.Body>Shared workspaces for up to 20 people.</Card.Body>
</Card>
);
},
};Disabled
export const Disabled: Story = {
render: () => (
<div className="flex gap-4">
<Card style={{ width: 240 }} disabled onSelect={fn()} selected={false}>
<Card.Header title="Disabled card" subtitle="Cannot be selected" />
</Card>
<Card style={{ width: 240 }} disabled selectionControl="checkbox" selected onSelect={fn()}>
<Card.Header title="Disabled with checkbox" />
<Card.Footer>
<Button disabled>Details</Button>
</Card.Footer>
</Card>
</div>
),
};Uncontrolled Selection
Last change: no change yet
export const UncontrolledSelection: Story = {
render: function UncontrolledSelectionCard() {
const [last, setLast] = React.useState('no change yet');
return (
<div className="flex flex-col gap-3" style={{ width: 360 }}>
<Card
defaultSelected={false}
onSelectionChange={(selected, { event }) => setLast(`${selected} by ${event.type}`)}
>
<Card.Header title="Uncontrolled card" subtitle="Click, or press Enter or Space" />
</Card>
<p className="text-wave-body-1">Last change: {last}</p>
</div>
);
},
};Focus Modes
export const FocusModes: Story = {
render: () => (
<div className="flex flex-col gap-4" style={{ width: 360 }}>
{(['off', 'no-tab', 'tab-exit', 'tab-only'] as const).map((focusMode) => (
<Card
key={focusMode}
focusMode={focusMode}
aria-label={`Card with focus mode ${focusMode}`}
>
<Card.Header title={`focusMode="${focusMode}"`} />
<Card.Footer>
<Button>Open</Button>
<Button>Share</Button>
</Card.Footer>
</Card>
))}
</div>
),
};Props
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
appearance | 'filled' | 'filled-alternative' | 'outline' | 'subtle' | No | 'filled' | Look of the card: |
size | 'small' | 'medium' | 'large' | No | 'medium' | Padding of the card's parts: |
orientation | 'horizontal' | 'vertical' | No | 'vertical' | Layout of the card's parts: |
selected | boolean | No | Whether the card is selected. Shown with the selected colors plus non-color cues: a 2px primary border (a 1px border plus an inset 1px ring), a Highlight outline in forced-colors mode, and a check glyph (with The state reaches assistive technology only on a selectable card ( | |
defaultSelected | boolean | No | Initially selected state for an uncontrolled card (Fluent UI's | |
onSelectionChange | (selected: boolean, details: CardSelectionDetails) => void | No | Called when the selected state changes, with the new state and the click, key press or checkbox change behind it (Fluent UI's | |
onSelect | (event?: React.SyntheticEvent<HTMLElement>) => void | No | Makes the card selectable: called when the card is activated by a click, Enter (on key down) or Space (on key up, like a native button) in the default mode, or when its built-in checkbox changes ( | |
disabled | boolean | No | false | Disables the card (Fluent UI's |
focusMode | 'off' | 'no-tab' | 'tab-exit' | 'tab-only' | No | 'off' | Focus management for the interactive content inside the card (Fluent UI's |
selectionControl | 'card' | 'checkbox' | No | 'card' | How a selectable card ( |
selectLabel | string | No | Accessible name of the built-in checkbox ( | |
checkbox | (Omit<SlotObject<'input'>, 'children'> & { children?: never }) | React.ReactNode | No | The built-in checkbox of | |
floatingAction | Slot<'span'> | No | An action over the top end corner of the card (a menu button, say). A card with one is positioned; with | |
slotProps | { checkmark?: SlotPart<'svg'> } | No | Props for the element the card draws over its corner, by part, merged into the part's own: your classes after the part's (yours win a conflict), your styles over its styles, your attributes and handlers added, your ref attached. Every attribute the card sets on the part is locked. A part takes no | |
as | React.ElementType | No | 'div' | Render as a different element or component (its props are type-checked). |
Any other prop is passed to the element it renders (HTMLDivElement).
Parts
checkmarkCard.HeaderCard.PreviewCard.BodyCard.Footer
Stable class names
| Part | Class |
|---|---|
root | wave-card |
checkbox | wave-card__checkbox |
checkmark | wave-card__checkmark |
floatingAction | wave-card__floating-action |