Card

A bordered surface grouping a heading, content and actions.

Source
$npx @dinachi/cli@latest add card

Create Account

Enter your details to create a new account.

CardTitle
CardDescription
CardFooter

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>
  );
}

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 listed in.
  • An action attached to a card through useAgentAction is listed as a region, named by its aria-label or else its first heading, the CardTitle.

API

classNamestring
Merged over the card classes.

Accessibility

  • Card has no role; its CardTitle heading gives it structure.
  • For a clickable card, put the link or button on the title.