Skip to content
GitHub (opens in a new tab)

Card

Framed tile with optional header, body, and footer actions.

stableMoleculecontracts/card.json

Preview

Cards

Framed tile. Section is unframed. Scorecard is a KPI.

Master

A login-style Card composing kit Buttons, Divider, Field and Input.

Login to your account

Enter your email below to login to your account.

Forgot your password?

Or continue with

Usage

Compose kit pieces in children. One primary action. Don't use Card for a lone metric.

Do's

  • Login or settings tiles
  • Feature summaries
  • Grouped content that should sit on a card surface
  • A table card: title over a DataTable (flush), with View all as a footer action
  • A compact table card: size sm + flush over a DataTable
  • A data tile with a header row (icon, eyebrow, time, X), a source line and a footer with Ask and one primary

Don'ts

<Card
  title="Login to your account"
  description="Enter your email below to login to your account."
  size="md"
  headerAction={{ label: "Sign Up", appearance: "ghost", mode: "neutral" }}
>
  <Field label="Name" htmlFor="card-login-name">
    <Input id="card-login-name" type="text" placeholder="Boris Jovanovic" />
  </Field>
  <Field label="Email" htmlFor="card-login-email">
    <Input id="card-login-email" type="email" />
  </Field>
  <Field label="Password" htmlFor="card-login-password" hint="Forgot your password?">
    <Input id="card-login-password" type="password" />
  </Field>
  <Field label="Workspace" htmlFor="card-login-workspace">
    <Input id="card-login-workspace" type="text" placeholder="Studio" />
  </Field>
  <Button appearance="solid" mode="primary" block>
    Login
  </Button>
  <Divider label="Or continue with" />
  <div className="layout-split">
    <Button appearance="outline" mode="neutral" block>
      Google
    </Button>
    <Button appearance="outline" mode="neutral" block>
      Apple
    </Button>
  </div>
</Card>

When to use

  • Login or settings tiles
  • Feature summaries
  • Grouped content that should sit on a card surface
  • A table card: title over a DataTable (flush), with View all as a footer action
  • A compact table card: size sm + flush over a DataTable
  • A data tile with a header row (icon, eyebrow, time, X), a source line and a footer with Ask and one primary

When not to use

  • Page-level grouping — use Section
  • One KPI — use Scorecard
  • Dialogs — use Modal or AlertDialog
  • Recommended insight — use InsightCard

What an agent reads

import { Card } from "agentic-ds-kit";
must
  • title is a heading when set (h2 by default, headingLevel 1, 3 or 4) with useId
  • aria-labelledby when title exists
  • An icon-only headerAction is a Button named by its label
  • A header action with href is a link (role link) named by its label, not a button
  • With icon, eyebrow, meta or onDismiss the header row comes before the title; eyebrow and meta are text, not headings; the icon tile is aria-hidden
  • The X is an IconButton named by KitLabels dismiss
  • source is referenced by aria-describedby on the article
  • Ask is a Button with a visible label; its MessageCircle icon is aria-hidden
  • The resting shadow (shadow.xs) is decorative and a shared default for Card and card frames (Scorecard, InsightCard, DataTable, DataGrid, charts); the border.faint edge keeps the card visible in both themes. Framed pieces inside a Card drop their own shadow.
defaults
  • headingLevel 2
  • size md
  • flush false
stops if
  • Do not invent local Card, Panel, or Tile
  • Do not use raw hex
  • Do not use Card as a Scorecard-in-disguise — do not put a lone metric here
  • Do not use Card for page grouping — that is unframed Section
  • Footer actions must be kit Buttons
  • Do not invent CardHeader components
  • headerAction is ghost/outline, not a second solid-primary
  • Do not nest a framed DataTable in a padded Card — set flush
  • Do not repeat the Card title as the DataTable caption — use DataTable ariaLabel
  • Do not put more than two header actions; move the rest to the footer or a DropdownMenu
  • Do not make an icon-only header action without a label that names what it does, e.g. Ask about Plan mix
  • Do not use headerAction href for new work; it is deprecated. Put View all in the footer actions
  • Do not make Ask a primary Button, or put a second solid-primary in the footer
  • Do not draw a local eyebrow, timestamp, close button or source line; pass eyebrow, meta, onDismiss and source
  • Do not skip heading levels: pick headingLevel from the headings above the card, and use 1 only when the card title is the page's only h1

From contracts/card.json: must is the a11y requirements, defaults the prop defaults, stops if the doNot rules where the agent asks instead of inventing a cousin.

Props

NameTypeRequiredDefaultNotes
titlestringNo—14/20 at heading weight (550) in both sizes: the smallest of three title sizes (page 24, section 18, card 14), the same as the agent cards.
headingLevelenumNo2Heading level of the title. Use 1 when the card title is the page heading (e.g. Sign in), 3 or 4 when the card sits under a page or Section heading. Only the element changes; the 16/24 title look stays the same.
descriptionstringNo——
childrenslotYes—Body. Compose kit Field/Input/Button/Badge/etc, never a local cousin. The card does not clip content, so DatePicker, Select, and DropdownMenu overlays open past its edge. A chart (LineChart, BarChart, ComboChart, PieChart, ScatterChart, Heatmap) directly in the body drops its own frame (border, radius, fill), padded or flush; in a flush Card it takes the card's inline padding so its title lines up with the card header.
sizesm | mdNomdsm = compact padding (space.4); md = space.6. Both use the 14/20 card title (type.size.bodySm / type.line.bodySm at type.weight.heading); only padding differs. The footer's block padding is space.4 on md and space.3 on sm. Size never sets width: the card fills its container, so width comes from the layout (wrap it, e.g. max-width 24rem, for a narrow tile).
headerActionobject | arrayNo—Header kit Button, or up to two (an array), e.g. an icon-only Ask and View all. Ghost or outline, not a second solid-primary. href is deprecated: it still renders a real link with the sm Button look, but prefer a footer action. iconStart adds a leading icon; iconOnly with iconStart makes it icon-only, named by label. More than two: the rest are ignored, with a warning in development.
flushbooleanNofalseBody edge to edge with no padding; header and footer keep padding with a divider. A DataTable directly in the body drops its own frame (border, radius, shadow). Its first and last columns take the card's inline padding at any size (space.6 md, space.4 sm), whatever the table's cellSize, so the title lines up with the first column and headerAction with the last. Use for table cards; give the DataTable ariaLabel instead of a caption so the title is not repeated.
actionsarrayNo—Footer kit Buttons (md), max 2, right-aligned after Ask, still one solid-primary per view. The footer sits under a divider.
iconKitIconNo—Header row: a small icon tile (surface.muted, icon.muted) before the eyebrow. aria-hidden.
badgeslotNo—One kit Badge right under the title, 4 below it, such as a connection status (a word plus an icon). Not for actions or long text.
eyebrowstringNo—Header row: short grey label, e.g. 'Analytics'. Caller copy, not a heading.
metastringNo—Header row: timestamp on the right, e.g. '12:04', tabular numbers. Not a heading.
onDismissfunctionNo—Header row: X IconButton sm (32), ghost neutral, named by KitLabels dismiss.
sourcestringNo—Grey caption under the body naming where the data comes from, e.g. 'Stripe · last 30 days'. Describes the article (aria-describedby).
onAskfunctionNo—Footer: neutral ghost Button sm with MessageCircle (aria-hidden) on the left. Shown only with askLabel.
askLabelstringNo—Caller label for Ask, e.g. 'Ask' or 'Ask in Chat'.
imageSrcstringNo—Full-bleed image above the content; its top corners take the card radius
imageAltstringNo—Required when imageSrc is set
  • Component
    →

    Section

    Grouped page block with optional heading, description, and actions.

  • Component
    →

    Scorecard

    one KPI with label, value, optional delta/trend/hint/badge

  • Component
    →

    Modal

    Dismissible overlay for short tasks, forms, or extra detail.

  • Component
    →

    AlertDialog

    Must-choose overlay that interrupts until the user cancels or confirms.