Skip to content

Card

The Card component provides a surface container used throughout the app for list items, settings panels, and status summaries. It sits on --background-surface within the three-level elevation hierarchy.

Variants

Cards support an optional variant prop that applies a status-themed left border and tinted background:

VariantToken usedContext
(default)--background-surfaceNeutral containers, settings panels
ok--status-ok-background-inverseIn-stock or success states
warning--status-warning-background-inverseLow-stock alerts
error--status-error-background-inverseExpiring or error states
inactive--status-inactive-background-inverseOut-of-stock or disabled items

Sub-components

Card composes four sub-components for layout:

<Card>
<CardHeader>
<CardTitle>Title</CardTitle>
<CardDescription>Supporting text</CardDescription>
</CardHeader>
<CardContent></CardContent>
<CardFooter></CardFooter>
</Card>

Usage

import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
// Default card
<Card>
<CardHeader><CardTitle>Milk</CardTitle></CardHeader>
<CardContent>2 left in pantry</CardContent>
</Card>
// Status variant
<Card variant="warning">
<CardContent>Running low — only 1 remaining</CardContent>
</Card>

Resources