Atoms
Card
Container component for grouping content with header, body, and footer.
shadcn/uiBased on shadcn/ui with Formance brand styling.
Installation#
npx shadcn@latest add @formance/cardInstall the following dependencies:
npm install class-variance-authority radix-uiCopy and paste the following code into your project.
Update the import paths to match your project setup.
Usage#
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle,} from '@/components/ui/card'<Card> <CardHeader> <CardTitle>Transaction Summary</CardTitle> <CardDescription>Overview of recent payment activity</CardDescription> </CardHeader> <CardContent> <p>Total processed: 1,024 transactions</p> </CardContent> <CardFooter> <p className="text-sm text-muted-foreground">Last updated 5 minutes ago</p> </CardFooter></Card>Heading level#
CardTitle renders a div, because the card does not know the heading level of the page. When the title is a heading, use asChild and give it the level of the page.
<CardTitle asChild> <h2>Transaction Summary</h2></CardTitle>The title keeps its classes and its data-slot. Typeset heading styles do not apply to it.
API reference#
Card#
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "muted" | - | The visual treatment. |
isDisabled | boolean | false | Fades and blurs the card, and blocks input. |
className | string | - | More classes for the card. |
CardTitle#
| Prop | Type | Default | Description |
|---|---|---|---|
asChild | boolean | false | Render the child, for example an h2 or h4. |
className | string | - | More classes for the title. |