Card
Groups content and actions about one subject. Three surfaces: elevated, filled and outlined. A card can also be one big control, like a link to an article.
Install
npx shadcn@latest add @nelumbo/cardVariants
Elevated is the default and floats on a soft shadow. Filled sits on a tonal surface, for grouping inside a page. Outlined is flat with a hairline, for dense or repeated layouts.
Header, content and actions
The header has a slot for an action in the corner. Footers hold buttons; put the main action last.
With media
CardMedia placed first runs edge to edge and takes the card's corners. Give it an aspect ratio so the layout doesn't jump while an image loads.
Interactive
Pass interactive and asChild with a link: the whole card becomes one link. Hover shows a faint overlay (elevated cards also lift), and pressing gives the same springy press as buttons. Don't nest other buttons inside.
Small
16px padding, for dashboards and dense grids.
Usage
import { Card, CardHeader, CardTitle, CardDescription, CardAction, CardContent, CardFooter, CardMedia } from "@/components/ui/card"<Card> <CardMedia><img src="/cover.jpg" alt="" /></CardMedia> <CardHeader> <CardTitle>Nelumbo 1.0</CardTitle> <CardDescription>Release notes</CardDescription> <CardAction><IconButton icon="more_vert" label="More" /></CardAction> </CardHeader> <CardFooter><Button>Read</Button></CardFooter></Card><Card asChild interactive variant="outlined"> <Link href="/guides/motion">…</Link></Card>Props
| Prop | Type | Default | Notes |
|---|---|---|---|
variant | "elevated" | "filled" | "outlined" | "elevated" | |
size | "default" | "sm" | "default" | 24px or 16px padding |
interactive | boolean | false | Hover, focus and press states for a card that is one control |
asChild | boolean | false | Render as the child element, e.g. a link |
CardMedia inset | boolean | false | Keep the padding and round the media's own corners |