Card
A bordered surface that groups related content and actions into one unit.
@garn/ui/cardDefault
Header + content + footer actions.
Installation
garn is copy-in — the garn CLI writes this component's source into your project, so you own and can edit it. It resolves any base files and installs the npm dependencies below for you.
npx garn-ui add card- Registry
card- Source
- card.tsx
- Deps
class-variance-authority- Registry deps
utils
Import
import { Card } from "@garn/ui/card";Props
Generated from the component's TypeScript types.
elevation- Description
- No description.
- Type
"hairline" | "raised"- Default
raised
Plus 280 inherited native <div> attributes.
Styling
Target these data-slots and remap these tokens to restyle without forking the component.
[data-slot="card"]| Property | Token | Tier |
|---|---|---|
padding | --garn-pad-surface | semantic · air |
headerGap | --garn-gap-field | semantic · air |
Overview
Card groups related content and actions into one bordered surface — a summary, a form section, a list item, a dashboard tile. The compound parts give it a predictable rhythm: CardHeader (with CardTitle + CardDescription), CardContent for the body, and CardFooter for actions, all sharing the surface padding and field gap. It's a container, not an interaction — for a whole clickable tile wrap it in a link or button; for a floating anchored surface use Popover.
Guidelines
Reach for a card to group, not to decorate. A border earns its keep when it sets genuinely related content apart from the page; boxing every element makes a layout noisy. Don't nest cards inside cards — switch to a Separator or spacing instead.
Keep one card to one idea. A card should cover a single entity or task; if it sprouts several unrelated sections and footers, split it. Use the CardHeader/Content/Footer regions so padding and spacing stay consistent rather than hand-rolling them.
Make whole-card affordances real. If the entire card is clickable, render it as one link/button with a single focus ring and accessible name — don't scatter nested click targets that fight the outer one. Right-align footer actions and lead with the primary one.
Best practices
- Compose with CardHeader / CardTitle / CardDescription / CardContent / CardFooter for consistent spacing.
- Put primary actions in CardFooter.
- Render CardTitle at the correct heading level so the page outline stays right.
- Don't hand-pad the card — the parts carry --garn-pad-surface.
- Don't nest cards deeply; flatten the layout or divide with a separator.
- Don't make the entire card a button — wrap a link or place a clear action inside.
Content guidelines
- Give the card a clear title and lead the body with the key fact.
- Label the card's action by outcome, and keep to one primary action per card.
Accessibility
- • Card is a styled <div> with no implicit role — structure meaning with a real heading (CardTitle) and the page's landmark regions.
- • If the whole card is a target, wrap a real link/button; don't bolt a click handler onto the surface.
- Status
- Stable
- Version
v0.3.0- Introduced
v0.1.0
garn doesn't yet record a per-release version history. This reflects the component's current lifecycle state; full changelog entries will appear once the metadata pipeline emits a lifecycle.history field.