$npx @dinachi/cli@latest add card
Create Account
Enter your details to create a new account.
CardTitleCardDescriptionCardFootercreate-account.tsx
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"
import { Button } from "@/components/ui/button"
export function CreateAccount() {
return (
<Card className="w-full max-w-sm">
<CardHeader>
<CardTitle>Create Account</CardTitle>
<CardDescription>Enter your details to create a new account.</CardDescription>
</CardHeader>
<CardContent className="space-y-4">
<div className="space-y-2">
<label htmlFor="name" className="text-sm font-medium">Name</label>
<input id="name" placeholder="John Doe" className="w-full rounded-md border border-input bg-background px-3 py-2 text-sm" />
</div>
<div className="space-y-2">
<label htmlFor="email" className="text-sm font-medium">Email</label>
<input id="email" type="email" placeholder="john@example.com" className="w-full rounded-md border border-input bg-background px-3 py-2 text-sm" />
</div>
</CardContent>
<CardFooter className="flex justify-between">
<Button variant="outline">Cancel</Button>
<Button>Create</Button>
</CardFooter>
</Card>
)
}Usage
import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "@/components/ui/card"
import { Button } from "@/components/ui/button"
export function UsageCard() {
return (
<Card className="max-w-sm">
<CardHeader>
<CardTitle>Usage</CardTitle>
<CardDescription>Requests this billing period.</CardDescription>
</CardHeader>
<CardContent>
<p className="text-3xl font-semibold">12,480</p>
</CardContent>
<CardFooter>
<Button variant="outline">View details</Button>
</CardFooter>
</Card>
)
}Examples
Create Account
Enter your details to create a new account.
A form card with actions in the footer.
import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from '@/components/ui/card';
import { Button } from '@/components/ui/button';
export function Example() {
return (
<Card className="w-full max-w-sm">
<CardHeader>
<CardTitle>Create Account</CardTitle>
<CardDescription>Enter your details to create a new account.</CardDescription>
</CardHeader>
<CardContent className="space-y-4">
<div className="space-y-2">
<label htmlFor="name" className="text-sm font-medium">Name</label>
<input id="name" placeholder="John Doe" className="w-full rounded-md border border-input bg-background px-3 py-2 text-sm" />
</div>
<div className="space-y-2">
<label htmlFor="email" className="text-sm font-medium">Email</label>
<input id="email" type="email" placeholder="john@example.com" className="w-full rounded-md border border-input bg-background px-3 py-2 text-sm" />
</div>
</CardContent>
<CardFooter className="flex justify-between">
<Button variant="outline">Cancel</Button>
<Button>Create</Button>
</CardFooter>
</Card>
);
}Card Title
Card description goes here.
This is the main content area of the card. You can add any content here.
A header with a title and description, then content.
import { Card, CardHeader, CardTitle, CardDescription, CardContent } from '@/components/ui/card';
export function Example() {
return (
<Card className="w-full max-w-sm">
<CardHeader>
<CardTitle>Card Title</CardTitle>
<CardDescription>Card description goes here.</CardDescription>
</CardHeader>
<CardContent>
<p className="text-sm text-muted-foreground">
This is the main content area of the card.
</p>
</CardContent>
</Card>
);
}Free Plan
For personal use
$0
per month
Pro Plan
For teams and businesses
$29
per month
Two cards side by side for comparing plans.
import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from '@/components/ui/card';
import { Button } from '@/components/ui/button';
export function Example() {
return (
<div className="grid gap-4 md:grid-cols-2 w-full max-w-2xl">
<Card>
<CardHeader>
<CardTitle>Free Plan</CardTitle>
<CardDescription>For personal use</CardDescription>
</CardHeader>
<CardContent>
<p className="text-3xl font-bold">$0</p>
<p className="text-sm text-muted-foreground">per month</p>
</CardContent>
<CardFooter>
<Button className="w-full" variant="outline">Get Started</Button>
</CardFooter>
</Card>
<Card className="border-primary">
<CardHeader>
<CardTitle>Pro Plan</CardTitle>
<CardDescription>For teams and businesses</CardDescription>
</CardHeader>
<CardContent>
<p className="text-3xl font-bold">$29</p>
<p className="text-sm text-muted-foreground">per month</p>
</CardContent>
<CardFooter>
<Button className="w-full">Subscribe</Button>
</CardFooter>
</Card>
</div>
);
}Project Status
ActiveLast updated 2 hours ago
Progress75%
A card with a hover shadow and a progress bar.
import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from '@/components/ui/card';
import { Button } from '@/components/ui/button';
export function Example() {
return (
<Card className="w-full max-w-sm hover:shadow-md transition-shadow cursor-pointer">
<CardHeader>
<div className="flex items-center justify-between">
<CardTitle>Project Status</CardTitle>
<span className="text-xs bg-green-100 text-green-800 px-2 py-1 rounded-full">Active</span>
</div>
<CardDescription>Last updated 2 hours ago</CardDescription>
</CardHeader>
<CardContent>
<div className="space-y-2">
<div className="flex justify-between text-sm">
<span>Progress</span>
<span className="font-medium">75%</span>
</div>
<div className="w-full h-2 bg-secondary rounded-full overflow-hidden">
<div className="h-full bg-primary rounded-full" style={{ width: '75%' }} />
</div>
</div>
</CardContent>
<CardFooter>
<Button variant="ghost" size="sm" className="ml-auto">View Details →</Button>
</CardFooter>
</Card>
);
}Notes
Heading level
CardTitle is always an h3. To change it, edit the copied file or put your own heading in CardHeader.
Spacing
Every part is a padded div and any can be left out. CardContent and CardFooter have no top padding; add pt-6 when one comes first.
Agents
- Not registered with the agent bridge.
- Inside an
AgentProvider,data-agent-in="Billing"on a Card names the container its controls are listedin. - An action attached to a card through
useAgentActionis listed as aregion, named by itsaria-labelor else its first heading, theCardTitle.
API
classNamestring
Merged over the card classes.Takes the props of the element it renders.
childrenReactNode
The title text.Takes the props of the element it renders.
Takes the props of the element it renders.
Takes the props of the element it renders.
Accessibility
- Card has no role; its
CardTitleheading gives it structure. - For a clickable card, put the link or button on the title.