Skip to content

Card

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

Card Title

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

Project Status
Last updated 2 hours ago

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

Selected Card

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

Pro plan
Press Enter or Space to select

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

Team plan
Click the card or the checkbox

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

Full Card
With all sections

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

filled
appearance
Body
filled-alternative
appearance
Body
outline
appearance
Body
subtle
appearance
Body
small
size
Body
medium
size
Body
large
size
Body
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

Preview
Quarterly report
Updated today
Highlights from the last three months.
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

Design review
Thursday, 10:00
Agenda and notes.
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

Team plan
Shared workspaces for up to 20 people.
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

Disabled card
Cannot be selected
Disabled with checkbox
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

Uncontrolled card
Click, or press Enter or Space

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

focusMode="off"
focusMode="no-tab"
focusMode="tab-exit"
focusMode="tab-only"
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

NameTypeRequiredDefaultDescription
appearance'filled' | 'filled-alternative' | 'outline' | 'subtle'No'filled'

Look of the card: filled (a surface with a border and a shadow), filled-alternative (a muted fill), outline (a border only) or subtle (no surface until hovered or selected). A selectable card gets a hover and pressed look for its appearance; the selected look is the same in every appearance.

size'small' | 'medium' | 'large'No'medium'

Padding of the card's parts: small 0.75rem, medium 1rem, large 1.25rem.

orientation'horizontal' | 'vertical'No'vertical'

Layout of the card's parts: vertical stacks them, horizontal puts them in a row (put the text parts in one wrapper element to keep them stacked beside a Card.Preview).

selectedbooleanNo

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 selectionControl="checkbox" the checked checkbox instead).

The state reaches assistive technology only on a selectable card (onSelect): as aria-pressed (default mode) or as the built-in checkbox's checked state. Without onSelect, selected is a visual state only (the glyph is decorative); state it in the content if it matters to screen-reader users, or make the card selectable.

defaultSelectedbooleanNo

Initially selected state for an uncontrolled card (Fluent UI's defaultSelected). Giving it makes the card selectable and lets it keep its own selected state, which selected controls instead when given. Without selected and defaultSelected, a card with only onSelect has no selected state of its own (it is a button that reports activations).

onSelectionChange(selected: boolean, details: CardSelectionDetails) => voidNo

Called when the selected state changes, with the new state and the click, key press or checkbox change behind it (Fluent UI's onSelectionChange(event, { selected })). Giving it makes the card selectable; without selected or defaultSelected the card keeps its own state, starting unselected. As a controlled card's parent decides the state, this reports the state the activation asks for.

onSelect(event?: React.SyntheticEvent<HTMLElement>) => voidNo

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 (selectionControl="checkbox"), with that event. Clicks and key presses that start inside a nested interactive element (a button, link, input or any element with tabindex), or in content portaled out of the card (a menu, popover or dialog opened from it), are ignored, so a footer action never selects the card. It is called on every activation, and onSelectionChange once per change of the state.

disabledbooleanNofalse

Disables the card (Fluent UI's disabled): a dimmed look with a not-allowed cursor, a boolean data-disabled and no activation. The card's own onClick, onKeyDown and onKeyUp are not attached and it selects nothing (onSelect and onSelectionChange are not called). A selectable card in the default mode reports aria-disabled="true" (a <button> rendered with as gets disabled) and leaves the tab order, as a disabled native button does; the built-in checkbox of selectionControl="checkbox" is disabled; focusMode is off. The content is yours to disable: a button inside the card stays enabled unless you disable it.

focusMode'off' | 'no-tab' | 'tab-exit' | 'tab-only'No'off'

Focus management for the interactive content inside the card (Fluent UI's focusMode): 'off' leaves focus alone; 'no-tab' makes the card one tab stop that Enter or F2 enters, with Tab trapped inside until Escape; 'tab-exit' is that without the trap; 'tab-only' makes the card a tab stop beside its content, no key intercepted. A card with a mode other than 'off' is role="group" (a role of yours replaces it) and a tab stop; give it a name (aria-label or aria-labelledby). Without effect on a selectable card in the default mode, which is a button, and on a disabled card: a development warning says so. Rendered as data-focus-mode.

selectionControl'card' | 'checkbox'No'card'

How a selectable card (onSelect) exposes its selection:
- 'card' (default): the card itself is the control — role="button", a tab stop, Enter and Space activation and aria-pressed={selected} when selected is defined. Use it only for cards **without** interactive content: a button inside a role="button" card is invalid (axe nested-interactive), and a development warning points here. A button's children are presentational, so the card's content is flattened into its name: a heading (e.g. <Card.Header as="h3">), list or other structure inside it is not exposed and cannot be reached by heading navigation (no warning covers this). Keep such cards short.
- 'checkbox': the card is not a widget; a built-in native checkbox (top end corner) carries selected and is named by the Card.Header title (or selectLabel). Pointer clicks on non-interactive card areas still toggle it. Use it for cards with actions, and for cards whose headings or other structure must stay navigable.

selectLabelstringNo

Accessible name of the built-in checkbox (selectionControl="checkbox"). Defaults to the Card.Header title, which the checkbox references with aria-labelledby.

checkbox(Omit<SlotObject<'input'>, 'children'> & { children?: never }) | React.ReactNodeNo

The built-in checkbox of selectionControl="checkbox": an object of <input> attributes is merged onto it (a class, aria-describedby, name; its type, checked state and change handling stay the card's), an element replaces it (give that control its own name and call onSelect from it), and null or false removes it, for a control you render elsewhere. Ignored with the default selectionControl. An <input> has no content, so the object takes no children (any are dropped).

floatingActionSlot<'span'>No

An action over the top end corner of the card (a menu button, say). A card with one is positioned; with selectionControl="checkbox" the built-in checkbox then moves to the top start corner. Content that renders nothing renders no element.

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 children (the card draws its glyph). The built-in checkbox and the floating action are the checkbox and floatingAction slots.

asReact.ElementTypeNo'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

  • checkmark
  • Card.Header
  • Card.Preview
  • Card.Body
  • Card.Footer

Stable class names

PartClass
rootwave-card
checkboxwave-card__checkbox
checkmarkwave-card__checkmark
floatingActionwave-card__floating-action