Card
A container for related content in three forms: static, pressable or a link.
import { Card } from '@windmorph/react';Props
Card 13 props
Renders a link. Navigation goes through React Aria's
RouterProviderwhen one is set.Disables the element: it can't be pressed or focused, and shows the disabled style.
The M3 style: filled, elevated or outlined.
The card is being dragged (picked up to move it): M3 raises it (filled and outlined to level 3, elevated to 4) and, on an interactive card, shows the dragged state layer. Set it from your drag and drop code; it sets
data-dragged.The card's content: its media, headline, text and actions.
Ref to the root element: the
<div>, or the<a>withhref.
Events
Handler that is called when the press is released over the target.
Handler that is called when a press interaction starts.
Handler that is called when a press interaction ends, either over the target or when the pointer leaves the target.
Handler that is called when the press state changes.
Handler that is called when a press is released over the target, regardless of whether it started on the target or not.
Also accepts every <a> attribute.
Tokens
M3's component tokens as CSS variables. Each is unset until you set it, on :root, a theme or any ancestor, and falls back to the default shown. The root carries data-variant (and data-size where it has sizes), which picks the variables that apply. See Component tokens in the Customisation guide.
| Variable | Default | Paints | Compose |
|---|---|---|---|
| Filled (variant) | |||
--md-comp-filled-card-container-color | var(--md-sys-color-surface-container-highest) | The container. | FilledCardTokens.ContainerColor |
--md-comp-filled-card-container-shape | var(--md-sys-shape-corner-medium) | The corners. | FilledCardTokens.ContainerShape |
| Elevated (variant) | |||
--md-comp-elevated-card-container-color | var(--md-sys-color-surface-container-low) | The container. | ElevatedCardTokens.ContainerColor |
--md-comp-elevated-card-container-shape | var(--md-sys-shape-corner-medium) | The corners. | ElevatedCardTokens.ContainerShape |
--md-comp-elevated-card-container-elevation | var(--md-sys-elevation-level-1) | The shadow at rest. | ElevatedCardTokens.ContainerElevation |
| Outlined (variant) | |||
--md-comp-outlined-card-container-color | var(--md-sys-color-surface) | The container. | OutlinedCardTokens.ContainerColor |
--md-comp-outlined-card-container-shape | var(--md-sys-shape-corner-medium) | The corners. | OutlinedCardTokens.ContainerShape |
--md-comp-outlined-card-outline-color | var(--md-sys-color-outline-variant) | The 1px border. | OutlinedCardTokens.OutlineColor |
Spec status
Built to the M3 Expressive card spec. Each item of its variants and configurations links to a live example; where the M3 Expressive column of the spec differs from the original M3 one, it wins.
| Item | Status | Details |
|---|---|---|
| Elevated card | Built | Variant · Variants |
| Filled card | Built | Variant · Variants |
| Outlined card | Built | Variant · Variants |
| Media, headline, supporting text and actions | Built | Use case · Content |
| Pressable and link cards | Built | Use case · Interactive |
| Clipped content | Extension | Cards clip their content to the 12px corners, as Compose does, so media gets rounded edges; overflow-visible turns it off. |
| Anatomy parts | Not built | No headline, media or actions sub-components: Compose ships none either, and layout utilities compose them. |
Elevated card
BuiltVariant · Variants
Filled card
BuiltVariant · Variants
Outlined card
BuiltVariant · Variants
Media, headline, supporting text and actions
BuiltUse case · Content
Pressable and link cards
BuiltUse case · Interactive
Clipped content
ExtensionCards clip their content to the 12px corners, as Compose does, so media gets rounded edges;
overflow-visibleturns it off.Anatomy parts
Not builtNo headline, media or actions sub-components: Compose ships none either, and layout utilities compose them.
Bundle size
Gzipped, as published: the component and the library code it imports. React, React Aria, Motion and the other dependencies aren't counted, and your bundler's minifier makes it smaller still. CI fails a change that grows it past its budget.
Card: 12.8 kB
M3 Expressive specs
- Shape
rounded-corner-medium- Variants
filled, elevated, outlined
Spec values
- Filled is
surface-container-highest, elevated issurface-container-lowat level 1, outlined issurfacewith a 1px outline. All have 12px corners andon-surfacecontent. - Interactive cards rise one level on hover (filled and outlined 0→1, elevated 1→2) and drop back while pressed or keyboard-focused; a focused outlined card's border turns
on-surface. - Set
draggedwhile a card is being moved: it rises to level 3 (elevated to 4), as M3 asks when picking up a card. - Disabled cards keep a faded container, as M3's disabled tokens ask: filled is
surface-variantand elevatedsurface, each at 38% over the card's own colour, and the outlined border isoutlineat 12%. Content ison-surfaceat 38%. - Content is clipped to the corners (
overflow-hidden), so media gets rounded edges; addoverflow-visibleto turn that off. - There are no anatomy sub-components (headline, media, actions) yet; layout utilities cover them.