Card
Simple bordered card primitives with floating border labels and semantic HTML support.
Installation
dgadd is not public on npm yet. Until the first release, pack @diffgazer/add from the repository and install that tarball into this app, which is what puts dgadd on pnpm exec.
The hosted registry is not public yet because r.b4r7.dev does not resolve. Use this source checkout or a local registry preview until the endpoint returns 200.
Diffgazer packages are not yet published to npm. Until the first release, pack @diffgazer/ui and @diffgazer/keys from the repository and install those tarballs.
UI components require Tailwind CSS v4. Local copy mode imports src/styles/styles.css; package mode uses @diffgazer/ui CSS once packages are available.
Usage
Examples
Surfaces
Interactive
Sizes
Header Action
Article (accessible)
API Reference
Card
Card.Label
Card.Title
Card.Description
Card.Header
Card.Action
Card.Content
Card.Footer
Accessibility
Notes
Surfaces
Card supports five surface treatments: flat (default clean border), stacked (paper-stack depth from a hard offset plate), inset (recessed surface step), dotted (dashed wireframe border), and glow (hard doubled outer edge). Depth comes from borders and background steps — cards never cast a soft shadow. Use surface='flat' for everyday cards, surface='stacked' for elevated emphasis, surface='inset' for recessed areas, surface='dotted' for drafts or placeholders, and surface='glow' for highlighted content.
Interactive
Add the interactive prop to enable hover and focus-visible states. Each surface has a unique hover treatment: flat brightens the border, stacked grows the offset plate, inset deepens the recessed fill, dotted brightens the dashed border, and glow strengthens the outer edge. The interactive prop only styles the surface — it does not make a div focusable. Render an interactive card on a focusable host (as='a' with href, or as='button' with onClick) or wrap its content in a link/button so keyboard users can reach it and the focus-visible treatment is reachable. See the Interactive example.
Floating Border Labels
Use CardLabel variant='border' for a boxed border label, or variant='gap' for a border cutout label with no border around the text. When using CardLabel, add pt-6 (or similar) to sibling CardContent to clear the floating label.
Padding rhythm
CardHeader, CardContent, and CardFooter all use px-6, so header text, body text, and footer actions share one vertical edge. Only the block padding differs per region (header py-3, content p-6, footer py-4). Override className if a product layout needs a different rhythm — but override all three regions together, never one.
Size
Card supports size='sm' | 'md' | 'lg' for max-width constraints. Default is full width.
Heading Level
CardTitle renders an h3 by default. Use the as prop to change the heading level (h2, h3, h4, h5).
Header Actions
Use CardAction inside CardHeader to place an action (button, badge) in the top-right corner. The header switches to a two-column grid layout automatically when CardAction is present.
Semantic HTML
Card renders a div by default. Use as='article' for self-contained content, as='section' for grouped content, or as='aside' for tangential content.
Accessible Article Cards
When using as='article', connect the card to its heading with aria-labelledby so screen readers announce card boundaries. Give CardTitle an id and pass the same id to Card's aria-labelledby. See the Article example.
Source
Install via CLI: pnpm exec dgadd add ui/card.
Highlighted source loads after this disclosure opens. Browse the source repository.