Card
A surface for grouping content, in three weights.
Examples
Playground
Variant
A bordered surface, a raised one, and a strong outline for a selected or highlighted card.
States
A card that is a link. Hover takes the strongest edge and lifts the card; focus takes the outline every control uses; pressed scales it. Forced, so they can be reviewed without a pointer.
In context
Cards as list items: `as="li"` keeps the list a list for a screen reader.
- Quarterly planAcceptedThree decisions, last changed on Tuesday.Ada Lovelace
- Hiring loopAcceptedThree decisions, last changed on Tuesday.Ada Lovelace
- Pricing reviewAcceptedThree decisions, last changed on Tuesday.Ada Lovelace
Install
npx shadcn add @hipuku/cardUsage
import { Card } from '@/components/haus/components/Card'
<Card>
<h3>Usage this month</h3>
<p>12,400 requests</p>
</Card>API
Card also takes its element's own attributes and forwards its ref. className lands on the root,
and your own rules win over Card's.
| Prop | Type | Description |
|---|---|---|
variant | "default" | "elevated" | "outlined" | |
padding | boolean | |
asChild | false | |
as | "div" | "article" | "section" | "li" | "aside" | The element to render. A card is often a list item or an article, and a
<div> in those places is a hole in the document outline that no styling
fixes. |
Variants
variant | Use it for |
|---|---|
default | A bordered surface. The one to reach for |
elevated | A card that floats or overlaps the page |
outlined | A selected or highlighted card |
Turn padding off for content that runs to the edge, such as an image at the top.
Choosing the element
Use as for the right element: li in a list of cards, article or aside where they belong.
For a card that is a link, pass the link as the single child with asChild:
<Card asChild>
<Link href="/projects/haus">haus</Link>
</Card>Accessibility
- A plain card takes no focus. Controls inside it keep their own.
- A card made a link or button with
asChildbecomes the control, with a visible focus outline. - Render a list of cards with
as="li"inside a list, so it is announced as a list.