Atoms

Card

Container component for grouping content with header, body, and footer.

shadcn/ui
Docs

Installation#

npx shadcn@latest add @formance/card

Install the following dependencies:

npm install class-variance-authority radix-ui

Copy 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#

PropTypeDefaultDescription
variant"muted"-The visual treatment.
isDisabledbooleanfalseFades and blurs the card, and blocks input.
classNamestring-More classes for the card.

CardTitle#

PropTypeDefaultDescription
asChildbooleanfalseRender the child, for example an h2 or h4.
classNamestring-More classes for the title.