Card
A content container with header, body and footer
Usage
import {Card} from "@peakui/react";Anatomy
import {Card} from "@peakui/react";
export default () => (
<Card>
<Card.Header>
<Card.Title>Title</Card.Title>
<Card.Description>Description</Card.Description>
</Card.Header>
<Card.Content>Content</Card.Content>
<Card.Footer>Footer</Card.Footer>
</Card>
);Examples
Variants
Horizontal Layout
Width and direction come from the consumer.
Compact Cards
Gallery
With Form
Card.Content is the body region; the form wraps it without breaking the card's padding.
Customization
Tailwind CSS
<Card className="w-[400px] gap-4 md:flex-row">Content</Card>Global CSS
@layer components {
.card {
border-radius: min(16px, var(--radius-2xl));
}
}Styling Reference
PeakUI follows the BEM methodology, so variants and states are plain class names you can target.
CSS Classes
The Card component uses these CSS classes (view source styles):
Base Class
.card- Base card styles: flex column, gap, padding, surface shadow and radius
Variant Classes
.card--default-bg-surface.card--secondary-bg-surface-secondary.card--tertiary-bg-surface-tertiary.card--transparent- No background, border or shadow
Element Classes
.card__header- Header region: flex column.card__title- Title:h3text styles.card__description- Description:ptext styles.card__content- Body region: flex column, takes the remaining space.card__footer- Footer region: flex row, centered
Slots
[data-slot="card"]- The root element[data-slot="card-header"]- The header region[data-slot="card-title"]- The title[data-slot="card-description"]- The description[data-slot="card-content"]- The body region[data-slot="card-footer"]- The footer region
API Reference
Card
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | - | The card content (required) |
variant | 'default' | 'secondary' | 'tertiary' | 'transparent' | 'default' | Surface level the card paints |
className | string | - | Additional classes |
render | DOMRenderFunction<'div', undefined> | - | Replaces the rendered <div> with your own element |
Every other attribute of a <div> is accepted.
Every variant except transparent provides SurfaceContext, so nested controls re-base their fills on the card's level.
Card.Header
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | - | The header content |
className | string | - | Additional classes |
render | DOMRenderFunction<'div', undefined> | - | Replaces the rendered <div> with your own element |
Every other attribute of a <div> is accepted.
Card.Title
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | - | The title text |
className | string | - | Additional classes |
render | DOMRenderFunction<'h3', undefined> | - | Replaces the rendered <h3> with your own element |
Every other attribute of an <h3> is accepted.
Card.Description
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | - | The description text |
className | string | - | Additional classes |
render | DOMRenderFunction<'p', undefined> | - | Replaces the rendered <p> with your own element |
Every other attribute of a <p> is accepted.
Card.Content
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | - | The body content |
className | string | - | Additional classes |
render | DOMRenderFunction<'div', undefined> | - | Replaces the rendered <div> with your own element |
Every other attribute of a <div> is accepted.
Card.Footer
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | - | The footer content |
className | string | - | Additional classes |
render | DOMRenderFunction<'div', undefined> | - | Replaces the rendered <div> with your own element |
Every other attribute of a <div> is accepted.