For the complete documentation index, see llms.txt. Markdown variants are available by appending .md to any URL or sending an Accept: text/markdown header. An agent skill is available at /.well-known/agent-skills/site-skill.md.
FrakmentFrakment

Card

A container for grouping related content and actions.

Web
Frakment
Event cover
Featured
Design systems meetup
A practical talk on component APIs, accessibility, and shipping faster.
card-image.tsx
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import {
  Card,
  CardAction,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle,
} from "@/components/ui/card";

export function CardImage() {
  return (
    <Card className="relative mx-auto w-full max-w-sm pt-0">
      <div className="absolute inset-0 z-30 aspect-video bg-black/35" />
      <img
        alt="Event cover"
        className="relative z-20 aspect-video w-full object-cover brightness-60 grayscale dark:brightness-40"
        src="https://avatar.vercel.sh/frakment1"
      />
      <CardHeader>
        <CardAction>
          <Badge variant="secondary">Featured</Badge>
        </CardAction>
        <CardTitle>Design systems meetup</CardTitle>
        <CardDescription>
          A practical talk on component APIs, accessibility, and shipping
          faster.
        </CardDescription>
      </CardHeader>
      <CardFooter>
        <Button className="w-full">View Event</Button>
      </CardFooter>
    </Card>
  );
}

Card is a flexible surface for content and actions. It supports a size prop (default / sm), an auto-spacing variable --card-spacing (default 16px, sm 12px), and image-friendly slots (pt-0 / rounded-t-xl).

Installation

Usage

card.tsx
import {
  Card,
  CardContent,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle,
} from "@/components/ui/card";
tsx
<Card>
  <CardHeader>
    <CardTitle>Frakment</CardTitle>
    <CardDescription>Registry primitives for React.</CardDescription>
  </CardHeader>
  <CardContent>
    <p>Copy-paste, not install.</p>
  </CardContent>
  <CardFooter>
    <Button>Open</Button>
  </CardFooter>
</Card>

Composition

Card
├── CardHeader
│   ├── CardTitle
│   ├── CardDescription
│   └── CardAction
├── CardContent
└── CardFooter

Examples

Small size

Pass size="sm" for tighter padding (12px) and smaller title.

Scheduled reports
Weekly snapshots. No more manual exports.
  • Choose a schedule (daily, or weekly).
  • Send to channels or specific teammates.
  • Include charts, tables, and key metrics.
card-small.tsx
import { ChevronRightIcon } from "lucide-react";
import { Button } from "@/components/ui/button";
import {
  Card,
  CardContent,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle,
} from "@/components/ui/card";

export function CardSmall() {
  const featureName = "Scheduled reports";

  return (
    <Card className="mx-auto w-full max-w-xs" size="sm">
      <CardHeader>
        <CardTitle>{featureName}</CardTitle>
        <CardDescription>
          Weekly snapshots. No more manual exports.
        </CardDescription>
      </CardHeader>
      <CardContent>
        <ul className="grid gap-2 py-2 text-sm">
          <li className="flex gap-2">
            <ChevronRightIcon className="text-muted-foreground mt-0.5 size-4 shrink-0" />
            <span>Choose a schedule (daily, or weekly).</span>
          </li>
          <li className="flex gap-2">
            <ChevronRightIcon className="text-muted-foreground mt-0.5 size-4 shrink-0" />
            <span>Send to channels or specific teammates.</span>
          </li>
          <li className="flex gap-2">
            <ChevronRightIcon className="text-muted-foreground mt-0.5 size-4 shrink-0" />
            <span>Include charts, tables, and key metrics.</span>
          </li>
        </ul>
      </CardContent>
      <CardFooter className="flex-col gap-2">
        <Button className="w-full" size="sm">
          Set up scheduled reports
        </Button>
        <Button className="w-full" size="sm" variant="outline">
          See what&apos;s new
        </Button>
      </CardFooter>
    </Card>
  );
}
tsx
<Card size="sm" className="mx-auto w-full max-w-xs">
  <CardHeader>
    <CardTitle>Scheduled reports</CardTitle>
    <CardDescription>Weekly snapshots.</CardDescription>
  </CardHeader>
  <CardContent>...</CardContent>
  <CardFooter>...</CardFooter>
</Card>

Custom spacing

Override --card-spacing via an inline arbitrary class — the entire card (header, content, footer) adapts.

Login to your account
Enter your email below to login to your account
card-spacing.tsx
"use client";

import * as React from "react";

import { Button } from "@/components/ui/button";
import {
  Card,
  CardAction,
  CardContent,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle,
} from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";

const spacingOptions = [
  {
    className: "[--card-spacing:--spacing(4)]",
    label: "16px",
    value: "4",
  },
  {
    className: "[--card-spacing:--spacing(5)]",
    label: "20px",
    value: "5",
  },
  {
    className: "[--card-spacing:--spacing(6)]",
    label: "24px",
    value: "6",
  },
  {
    className: "[--card-spacing:--spacing(8)]",
    label: "32px",
    value: "8",
  },
];

export function CardSpacing() {
  const [spacing, setSpacing] = React.useState("4");
  const selectedSpacing = spacingOptions.find(
    (option) => option.value === spacing
  );

  return (
    <div className="mx-auto grid w-full max-w-sm gap-4">
      <ToggleGroup
        className="justify-center"
        onValueChange={(value) => {
          if (value) {
            setSpacing(value);
          }
        }}
        size="sm"
        type="single"
        value={spacing}
        variant="outline"
      >
        {spacingOptions.map((option) => (
          <ToggleGroupItem key={option.value} value={option.value}>
            {option.label}
          </ToggleGroupItem>
        ))}
      </ToggleGroup>
      <Card className={selectedSpacing?.className}>
        <CardHeader>
          <CardTitle>Login to your account</CardTitle>
          <CardDescription>
            Enter your email below to login to your account
          </CardDescription>
          <CardAction>
            <Button variant="link">Sign Up</Button>
          </CardAction>
        </CardHeader>
        <CardContent>
          <form>
            <div className="flex flex-col gap-6">
              <div className="grid gap-2">
                <Label htmlFor="email-spacing">Email</Label>
                <Input
                  id="email-spacing"
                  placeholder="m@example.com"
                  required
                  type="email"
                />
              </div>
              <div className="grid gap-2">
                <div className="flex items-center">
                  <Label htmlFor="password-spacing">Password</Label>
                  <a
                    className="ml-auto inline-block text-sm underline-offset-4 hover:underline"
                    href="#"
                  >
                    Forgot your password?
                  </a>
                </div>
                <Input id="password-spacing" required type="password" />
              </div>
            </div>
          </form>
        </CardContent>
        <CardFooter className="flex-col gap-2">
          <Button className="w-full" type="submit">
            Login
          </Button>
          <Button className="w-full" variant="outline">
            Login with Google
          </Button>
        </CardFooter>
      </Card>
    </div>
  );
}
tsx
<Card className="[--card-spacing:--spacing(6)]">...</Card>

Edge to edge

Negate --card-spacing on CardContent (-mb-(--card-spacing), -mx-(--card-spacing)) for full-bleed sections like scrollable terms.

Terms of Service
Review the terms before accepting the agreement.

These terms govern your use of the workspace, including access to shared documents, project files, and collaboration tools.

You are responsible for the content you upload and for ensuring that your team has the appropriate permissions to view or edit it.

We may update features or limits as the service evolves. When those changes materially affect your workflow, we will notify your workspace administrators.

By continuing, you agree to keep your account credentials secure and to follow your organization's acceptable use policies.

card-edge-to-edge.tsx
import { Button } from "@/components/ui/button";
import {
  Card,
  CardContent,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle,
} from "@/components/ui/card";

export function CardEdgeToEdge() {
  return (
    <Card className="mx-auto w-full max-w-sm">
      <CardHeader>
        <CardTitle>Terms of Service</CardTitle>
        <CardDescription>
          Review the terms before accepting the agreement.
        </CardDescription>
      </CardHeader>
      <CardContent className="-mb-(--card-spacing)">
        <div className="bg-muted/50 -mx-(--card-spacing) max-h-48 space-y-4 overflow-y-scroll border-t px-(--card-spacing) py-4 text-sm leading-relaxed">
          <p>
            These terms govern your use of the workspace, including access to
            shared documents, project files, and collaboration tools.
          </p>
          <p>
            You are responsible for the content you upload and for ensuring that
            your team has the appropriate permissions to view or edit it.
          </p>
          <p>
            We may update features or limits as the service evolves. When those
            changes materially affect your workflow, we will notify your
            workspace administrators.
          </p>
          <p>
            By continuing, you agree to keep your account credentials secure and
            to follow your organization&apos;s acceptable use policies.
          </p>
        </div>
      </CardContent>
      <CardFooter className="justify-end gap-2">
        <Button variant="outline">Decline</Button>
        <Button>Accept</Button>
      </CardFooter>
    </Card>
  );
}
tsx
<CardContent className="-mb-(--card-spacing)">
  <div className="-mx-(--card-spacing) px-(--card-spacing) py-4">...</div>
</CardContent>

With image

Any <img> as the first child gets pt-0 + rounded top automatically — no extra classes needed on the image itself.

Event cover
Featured
Design systems meetup
A practical talk on component APIs, accessibility, and shipping faster.
card-image.tsx
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import {
  Card,
  CardAction,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle,
} from "@/components/ui/card";

export function CardImage() {
  return (
    <Card className="relative mx-auto w-full max-w-sm pt-0">
      <div className="absolute inset-0 z-30 aspect-video bg-black/35" />
      <img
        alt="Event cover"
        className="relative z-20 aspect-video w-full object-cover brightness-60 grayscale dark:brightness-40"
        src="https://avatar.vercel.sh/frakment1"
      />
      <CardHeader>
        <CardAction>
          <Badge variant="secondary">Featured</Badge>
        </CardAction>
        <CardTitle>Design systems meetup</CardTitle>
        <CardDescription>
          A practical talk on component APIs, accessibility, and shipping
          faster.
        </CardDescription>
      </CardHeader>
      <CardFooter>
        <Button className="w-full">View Event</Button>
      </CardFooter>
    </Card>
  );
}
tsx
<Card className="pt-0">
  <img alt="..." className="aspect-video w-full object-cover" src="..." />
  <CardHeader>...</CardHeader>
</Card>

In Context

Project list

frakment/ui
Primitives for product surfaces.

42 components. Radix-based. Copy-paste first.

frakment/ai
Chat, agent, and reasoning primitives.

Message, Bubble, Trace, Attachment.

card-project-list.tsx
import { Button } from "@/components/ui/button";
import {
  Card,
  CardContent,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle,
} from "@/components/ui/card";

export function CardProjectList() {
  return (
    <div className="mx-auto w-full max-w-sm space-y-3">
      <Card>
        <CardHeader>
          <CardTitle>frakment/ui</CardTitle>
          <CardDescription>Primitives for product surfaces.</CardDescription>
        </CardHeader>
        <CardContent>
          <p className="text-sm">
            42 components. Radix-based. Copy-paste first.
          </p>
        </CardContent>
        <CardFooter>
          <Button size="sm" variant="outline">
            View
          </Button>
        </CardFooter>
      </Card>
      <Card>
        <CardHeader>
          <CardTitle>frakment/ai</CardTitle>
          <CardDescription>
            Chat, agent, and reasoning primitives.
          </CardDescription>
        </CardHeader>
        <CardContent>
          <p className="text-sm">Message, Bubble, Trace, Attachment.</p>
        </CardContent>
        <CardFooter>
          <Button size="sm" variant="outline">
            View
          </Button>
        </CardFooter>
      </Card>
    </div>
  );
}

API Reference

Card

PropTypeDefaultDescription
size
defaultsm
—Root padding via --card-spacing (16px → 12px) and smaller title.

Other parts

All other parts extend React.ComponentProps<"div"> and set data-slot="card-*" for styling hooks.

CSS Variables

VariableDefaultPurpose
--card-padding--spacing(6)Inner padding
--card-radius--radius-xlCorner radius
--card-spacing--spacing(4)Gap between sections

Variants

VariantUse case
defaultStandard surface
outlineBordered, no elevation

Data Attributes

AttributeValues
data-slotcard, card-header, card-title, card-description, card-action, card-content, card-footer

Accessibility

  • Card renders a plain <div> with data-slot="card". It has no role by default; add one when the card represents a distinct region (e.g. role="region" with aria-labelledby).
  • CardTitle renders an h3. Use one CardTitle per card so document outline stays flat.
  • Do not attach onClick to the card surface. If the whole card is clickable, wrap it in a link and keep the actions as separate focusable elements.
  • Interactive content inside CardFooter receives focus in DOM order; keep destructive actions last.

Best Practices

  • One idea per card. Split content into multiple cards rather than stacking everything inside one.
  • Do not nest cards. Use Separator to divide sections inside a card.
  • Keep actions in the footer. CardFooter aligns buttons and metadata to the end.
  • Use CardTitle as a heading, not a label. For labels, use text-sm font-medium on a span.
  • Avoid full-surface hover unless the whole card is clickable. Mixed hover states confuse users.
  • Item — row-level container
  • Accordion — collapsible content
  • Tabs — switch content panes