Card
elements man ui/templates/cardA surface with a header, body and footer, built on the base card styles.
Exampleimport { Card, CardHeader, CardTitle, CardDescription, CardAction, CardContent, CardFooter, } from "@elements/ui/card"; import { Button } from "@elements/ui/button"; <Card title="Login to your account" description="Enter your email below to login."> <Button slot="action" variant="link">Sign up</Button> <CardContent>...</CardContent> <CardFooter align="stack"> <Button variant="primary">Login</Button> </CardFooter> </Card>
Anything in the action slot sits at the header's top right; it needs no
CardAction wrapper. To name a landmark by the card's title, give the title
an id and point aria-labelledby at it.
Example<section aria-labelledby="billing-title"> <Card title="November 2026" titleId="billing-title"> <Badge slot="action">$2,870</Badge> <CardContent>...</CardContent> </Card> </section>
Parts
| Part | What it is |
|---|---|
CardHeader |
.card-head: title and description, with the action at the top right. |
CardTitle |
.card-title, role=heading with aria-level. |
CardDescription |
.card-description, helper text. |
CardAction |
.card-action, top right of the header. |
CardContent |
.card-body, the padded body. |
CardFooter |
.card-foot, actions on a tinted strip. |
.card-bleed |
Content that runs edge to edge inside the body. |
--card-spacing |
The padding every part uses. Set it on the card to change them all. |
Attributes
Card
| Attribute | Type | Default | Description |
|---|---|---|---|
title |
string |
"" |
Renders a header with a title. |
description |
string |
"" |
Renders a description in that header. |
size |
"md" | "sm" |
"md" |
sm pads with the theme's small surface padding. |
level |
1 | 2 | 3 | 4 | 5 | 6 |
3 |
Heading level of the title. |
titleId |
string |
"" |
id on the title, for aria-labelledby. |
class |
string |
"" |
Extra classes on the surface. |
attrs |
Record<string, string | number | boolean | undefined> |
{} |
Other attributes: id, style (set --card-spacing), aria-*. |
CardTitle
| Attribute | Type | Default | Description |
|---|---|---|---|
level |
1 | 2 | 3 | 4 | 5 | 6 |
3 |
aria-level of the heading. |
id |
string |
"" |
id on the heading, for aria-labelledby. |
attrs |
Record<string, string | number | boolean | undefined> |
{} |
Other attributes for the heading: data-*, title. |
CardFooter
| Attribute | Type | Default | Description |
|---|---|---|---|
align |
"end" | "start" | "stack" |
"end" |
Where the footer's actions sit; stack is full-width buttons in a column. |
every part
| Attribute | Type | Default | Description |
|---|---|---|---|
class |
string |
"" |
Extra classes. |
Slots
| Slot | Part | Content |
|---|---|---|
default |
Card |
The parts, an image, anything. |
action |
Card |
The header action when the header comes from title: a Button, a Badge or a CardAction, placed at the top right. |
default |
each part |
The part's content. |
Data attributes
| Attribute | Values | On |
|---|---|---|
data-size |
"md" | "sm" |
root |
data-slot |
"card" | "card-header" | "card-title" | "card-description" | "card-action" | "card-content" | "card-footer" |
every part |
Accessibility
- The title is role="heading" with aria-level (3 by default), so the outline is right whatever size the theme draws it.
- The card itself is a div. Put it in an
<article>or a<section>labelled by the title's id (titleId, or CardTitle's id) when it is a landmark.
See also
- Button (opens in a new tab): A button or a link that looks like one, in six variants and four sizes.
- Badge (opens in a new tab): A small label for a status, a count or a category, built on the pill.
- Alert (opens in a new tab): A callout that draws attention to a message, with an icon, a title and an action.
- Icon (opens in a new tab): An inline stroke icon from the set the templates draw their own controls with, sized in pixels and colored by the text around it.
- Kbd (opens in a new tab): A keyboard key or shortcut, as text.
- Separator (opens in a new tab): A horizontal or vertical rule between content, semantic or decorative.