Card
A puffy card on a candy edge, with a wash of its colour across the top. Make
it interactive and it leans toward the pointer, catches a glare, grows a
star on its corner and wobbles like jelly when you click it. ぷるん
Installation
❯ npx shadcn@latest add https://yan.moe/r/card.jsonUsage
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"<Card color="mint">
<CardHeader>
<CardTitle>Matcha roll</CardTitle>
<CardDescription>Whipped cream, red bean, a little bitter.</CardDescription>
</CardHeader>
<CardContent>…</CardContent>
</Card>Examples
Interactive
interactive turns the whole card into one target. Move the pointer over it
and it leans after you with a glare; click and it squashes, throws emphasis
lines and dust, and bursts. Pair it with asChild and a link or a button so
it can be focused. Each card here takes a different recipe from Effects.
<Card interactive asChild fx={fxRecipes.petals}>
<Link href="/sakura">…</Link>
</Card>Accessibility
- A plain card is a
<div>with no role. Give it a heading inside. - An interactive card needs
asChildwith a link or a button: a bare<div>cannot be reached by keyboard. - The lean and the glare follow a mouse or a pen, not a finger.
- With
prefers-reduced-motion: reduce, the lean, the wobble and the particles are skipped.
API
| Prop | Type | Default |
|---|---|---|
colorColour of the rim, the wash and the edge underneath. | "sakura" | "lavender" | "mint" | "sky" | "lemon" | "peach" | "sakura" |
interactiveLean, glare, press and a click burst for the whole card. | boolean | false |
intensityFor an interactive card. kawaii: lean, glare, corner star, then wobble, lines, dust and a burst on click. subtle: a lift and a few sparkles. off: none. | "kawaii" | "subtle" | "off" | "kawaii" |
fxOverrides for the click burst of an interactive card. | BurstOptions | - |
asChildMerge props onto the child element instead of rendering a <div>. | boolean | false |