Card
A self-contained, linked item among peers, composed from semantic HTML with optional parts for media, title, meta, body and footer.
import {
Card,
CardBody,
CardMeta,
CardTitle,
CardTitleLink,
} from '@fairgarden/design/content/card'
CardTitleLink is the card's one primary link: its hit area stretches over the whole card, and the card draws the focus ring outside its frame. The root is an inline-size container, so give it a width in shrink-to-fit layouts.
Kinds
Kinds
Editorial cards are bare by default; faced adds a face and an edge. kind="block" is the featured block-edge card, one family per page. kind="entry" is the hero's compact entry card: a white face with a 2 px --primary12 edge, the square CardMedia image flush to its start edge and as tall as the card, then a CardKicker category in caps and the title link. It stays horizontal at every width; the Hero lays up to three of them across its bottom edge.
Protect the headwaters
Lead, footers and unavailable
Lead, pinned footers and unavailable
lead makes the one lead card of a grid horizontal once its card-grid container reaches 944 px: the media takes 5 of 12 columns and the text the other 7, and a faced card's photo runs flush down its start edge. Below that it stacks like any card. Cards in a grid row share one height, and CardFooter is pinned to the bottom, so a row's actions line up. disabled marks an unavailable card (a sold-out product, a past event): a dotted edge, muted title and body, and no action. Say why in words, with a Badge. CardChoice holds an option card's Checkbox or Radio; when it's checked the edge steps to 2 px in the selection edge color.
The river comes back
Owl prowl
Seed library open house
Spring bird count
Primary and secondary
Primary and secondary
primary and secondary pass through to the card's face scope, so rules, text and the title's accent re-resolve together.
Scope defaults
Royal pairing
Clay pairing
On grounds
On paper, forest and leaf
A faced card nests its own Ground: white on a page ground, and a paper light island inside a field (forest, leaf) or the night band. Its edge is that face's own edge color, so it stays visible on every ground.
Night walk
Night walk
Night walk
API Reference
Card
The card frame. Plain children are fine (<Card>…</Card>); the optional
parts CardMedia, CardKicker, CardTitle (+ CardTitleLink),
CardMeta, CardBody, CardChoice and CardFooter give the §12.2
anatomy and rhythm. Put a
leading CardMedia first (a direct child) to run it flush to the frame.
In a grid row, cards share one height and the footer sits at the bottom.
Renders <article>; pass render={<li />} or similar to change it. The
root is an inline-size container, so give it a width in shrink-to-fit
contexts (flex items without stretch, floats).
| Prop | Type | Description |
|---|---|---|
faced | | Adds the face (a nested |
kind | | Editorial (default): open (bare) by default per §12.2; |
lead | | The single lead card of a grid: horizontal, media 5 columns and
text 7, once its |
primary | | Primary Radix scale for the card and its face: text, rules and edges. Never defaulted; omitted, it inherits the scope [D133]. |
secondary | | Secondary Radix scale for the card and its face: the accents, such as the title link’s underline. Never defaulted; omitted, it inherits the scope. |
disabled | | Unavailable (a sold-out product, a past event): title and body in
|
CardTitle and CardTitleLink
type-itemhead in --primary12. Renders <h3>; pass render={<h2 />} to fit the outline.
The card’s one primary link, inside CardTitle. A §9.3 title Link: its
hit area stretches over the whole card; hover, focus and press underline
the title; the card draws the focus ring outside its frame.
| Prop | Type | Description |
|---|---|---|
external | | Adds the arrow-open mark and “(external site)” for assistive technology.
Default |
index | | Adds the screen-only visited ✓ used in long indexes, such as reference
and archive lists. Default |
list | | With |
muted | | Rests in |
primary | | Primary Radix scale: the link text and focus ring. Never defaulted; omitted, it inherits the scope [D133]. |
secondary | | Secondary Radix scale: the accent underline. Never defaulted; omitted, it inherits the scope. |
className | | Extra class names, added after the module’s own. |
CardMeta, CardBody and CardFooter
Date, format, place joined by “·": type-caption in --role-muted.
Two to four lines of type-body-ui in --primary12.
The action row (§12.2 part action): a sm outline Button, or a
“READ MORE ›” standalone Link. Pinned to the card’s bottom, so a grid
row’s actions align (§12.3); sits above the stretched title link; stacks
below 360 px of card width; removed while the card is disabled.
CardChoice
The option-card indicator slot (§12.2 part choice, §10.7): put the
card’s Checkbox or Radio here. Its data-checked steps the faced edge to
--border-size-2 in --role-select-edge; its data-disabled draws the
unavailable edge and mutes the title and body. Sits above the stretched
title link as its own control.
CardMedia and CardKicker
Photo or drawing (figure with an img). Flush when first in a faced card; inset in a block card.
The kicker above the title (§12.2 part kicker): a topic Tag, or a
category in type-label caps in --primary12, as on the entry card.
Additional types
CardBodyProps
Props for CardBody: div props and render.
type CardBodyProps = useRender.ComponentProps<'div'>CardChoiceProps
Props for CardChoice: div props and render.
type CardChoiceProps = useRender.ComponentProps<'div'>CardFooterProps
CardKickerProps
Props for CardKicker: paragraph props and render.
type CardKickerProps = useRender.ComponentProps<'p'>CardMediaProps
Props for CardMedia: figure props and render.
type CardMediaProps = useRender.ComponentProps<'figure'>CardMetaProps
Props for CardMeta: paragraph props and render.
type CardMetaProps = useRender.ComponentProps<'p'>CardProps
Props for Card: article props, render, and the kind, face and color axes.
type CardProps =
| (React.ClassAttributes<HTMLElement> &
React.HTMLAttributes<HTMLElement> &
__type & {
primary?:
| 'ruby'
| 'olive'
| 'sage'
| 'slate'
| 'sand'
| 'gray'
| 'mauve'
| 'brown'
| 'bronze'
| 'gold'
| 'red'
| 'crimson'
| 'tomato'
| 'pink'
| 'plum'
| 'indigo'
| 'iris'
| 'violet'
| 'purple'
| null;
secondary?:
| 'ruby'
| 'olive'
| 'sage'
| 'slate'
| 'sand'
| 'gray'
| 'mauve'
| 'brown'
| 'bronze'
| 'gold'
| 'red'
| 'crimson'
| 'tomato'
| 'pink'
| 'plum'
| 'indigo'
| 'iris'
| 'violet'
| 'purple'
| 'amber'
| 'blue'
| 'cyan'
| 'grass'
| 'green'
| 'jade'
| 'lime'
| 'mint'
| 'orange'
| 'sky'
| 'teal'
| 'yellow'
| null;
disabled?: boolean;
} & { kind?: 'editorial'; faced?: boolean; lead?: boolean })
| (React.ClassAttributes<HTMLElement> &
React.HTMLAttributes<HTMLElement> &
__type & {
primary?:
| 'ruby'
| 'olive'
| 'sage'
| 'slate'
| 'sand'
| 'gray'
| 'mauve'
| 'brown'
| 'bronze'
| 'gold'
| 'red'
| 'crimson'
| 'tomato'
| 'pink'
| 'plum'
| 'indigo'
| 'iris'
| 'violet'
| 'purple'
| null;
secondary?:
| 'ruby'
| 'olive'
| 'sage'
| 'slate'
| 'sand'
| 'gray'
| 'mauve'
| 'brown'
| 'bronze'
| 'gold'
| 'red'
| 'crimson'
| 'tomato'
| 'pink'
| 'plum'
| 'indigo'
| 'iris'
| 'violet'
| 'purple'
| 'amber'
| 'blue'
| 'cyan'
| 'grass'
| 'green'
| 'jade'
| 'lime'
| 'mint'
| 'orange'
| 'sky'
| 'teal'
| 'yellow'
| null;
disabled?: boolean;
} & { kind: 'block'; faced?: undefined; lead?: undefined })
| (React.ClassAttributes<HTMLElement> &
React.HTMLAttributes<HTMLElement> &
__type & {
primary?:
| 'ruby'
| 'olive'
| 'sage'
| 'slate'
| 'sand'
| 'gray'
| 'mauve'
| 'brown'
| 'bronze'
| 'gold'
| 'red'
| 'crimson'
| 'tomato'
| 'pink'
| 'plum'
| 'indigo'
| 'iris'
| 'violet'
| 'purple'
| null;
secondary?:
| 'ruby'
| 'olive'
| 'sage'
| 'slate'
| 'sand'
| 'gray'
| 'mauve'
| 'brown'
| 'bronze'
| 'gold'
| 'red'
| 'crimson'
| 'tomato'
| 'pink'
| 'plum'
| 'indigo'
| 'iris'
| 'violet'
| 'purple'
| 'amber'
| 'blue'
| 'cyan'
| 'grass'
| 'green'
| 'jade'
| 'lime'
| 'mint'
| 'orange'
| 'sky'
| 'teal'
| 'yellow'
| null;
disabled?: boolean;
} & { kind: 'entry'; faced?: undefined; lead?: undefined })CardTitleLinkProps
Props for CardTitleLink: Link props except kind, which is always title.
type CardTitleLinkProps = {
/** Extra class names, added after the module's own. */
className?: string;
/**
* Primary Radix scale: the link text and focus ring. Never defaulted;
* omitted, it inherits the scope [D133].
*/
primary?:
| 'ruby'
| 'olive'
| 'sage'
| 'slate'
| 'sand'
| 'gray'
| 'mauve'
| 'brown'
| 'bronze'
| 'gold'
| 'red'
| 'crimson'
| 'tomato'
| 'pink'
| 'plum'
| 'indigo'
| 'iris'
| 'violet'
| 'purple'
| null;
/**
* Secondary Radix scale: the accent underline. Never defaulted; omitted,
* it inherits the scope.
*/
secondary?:
| 'ruby'
| 'olive'
| 'sage'
| 'slate'
| 'sand'
| 'gray'
| 'mauve'
| 'brown'
| 'bronze'
| 'gold'
| 'red'
| 'crimson'
| 'tomato'
| 'pink'
| 'plum'
| 'indigo'
| 'iris'
| 'violet'
| 'purple'
| 'amber'
| 'blue'
| 'cyan'
| 'grass'
| 'green'
| 'jade'
| 'lime'
| 'mint'
| 'orange'
| 'sky'
| 'teal'
| 'yellow'
| null;
/**
* With `kind="nav"`: a list link (nav-panel, footer, drawer and breadcrumb
* lists), whose hover is `--role-link-hover` color only, plus the
* `--border-size-1-5` `--role-accent` underline where that ink is
* `--primary12`. Without it, `nav` is bare navigation text (bar and
* utility items, page numbers, toolbar links), whose hover is the
* `--border-size-2` `--role-accent` underline (§9.3) [D181]. Default
* `false`.
*/
list?: boolean | null;
/**
* Adds the screen-only visited ✓ used in long indexes, such as reference
* and archive lists. Default `false` [D174, D175].
*/
index?: boolean | null;
/**
* Adds the arrow-open mark and "(external site)" for assistive technology.
* Default `false`.
*/
external?: boolean | null;
/**
* Rests in `--role-muted` instead of `--primary12`, as a breadcrumb's
* ancestors. Hover takes `--role-link-hover` only (the underline is added
* where that ink is `--primary12`); with `kind="nav"` it replaces the bar
* item's bare-text underline (§9.3, §9.8) [D181]. Default `false`.
*/
muted?: boolean | null;
}CardTitleProps
Props for CardTitle: heading props and render (default <h3>).
type CardTitleProps = useRender.ComponentProps<'h3'>Specification: DESIGN-SYSTEM.md §12.2 (card).