Skip to Content
Getting startedFoundationsComponentsPackagesTools

Card

A surface for grouping content, in three weights.

Examples

Playground

Quarterly planAccepted
Three decisions, last changed on Tuesday.
Ada Lovelace

Variant

A bordered surface, a raised one, and a strong outline for a selected or highlighted card.

default
Quarterly planAccepted
Three decisions, last changed on Tuesday.
Ada Lovelace
elevated
Quarterly planAccepted
Three decisions, last changed on Tuesday.
Ada Lovelace
outlined
Quarterly planAccepted
Three decisions, last changed on Tuesday.
Ada Lovelace

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 planAccepted
    Three decisions, last changed on Tuesday.
    Ada Lovelace
  • Hiring loopAccepted
    Three decisions, last changed on Tuesday.
    Ada Lovelace
  • Pricing reviewAccepted
    Three decisions, last changed on Tuesday.
    Ada Lovelace

Install

npx shadcn add @hipuku/card

Usage

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.

PropTypeDescription
variant"default" | "elevated" | "outlined"
paddingboolean
asChildfalse
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

variantUse it for
defaultA bordered surface. The one to reach for
elevatedA card that floats or overlaps the page
outlinedA 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 asChild becomes 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.

On this page