A composable content surface with compact spacing, an action slot, and optional interactive feedback.
What changed
- 1.0.1 Oct 11, 2026Hover lift and press depth follow the theme's --bm-lift and --bm-hover tokens. Unchanged by default.
- 1.0.0 Sep 29, 2026First release.
import { ArrowUpRight, TrendingUp } from "lucide-react"
import {
Card,
CardHeader,
CardTitle,
CardDescription,
CardAction,
CardContent,
CardFooter,
} from "@/components/ballmac/card"
import { Badge } from "@/components/ballmac/badge"
export default function CardDemo() {
return (
<Card interactive className="w-full max-w-sm">
<CardHeader>
<CardTitle>Monthly overview</CardTitle>
<CardDescription>Activity across your workspace</CardDescription>
<CardAction>
<TrendingUp aria-hidden="true" className="size-5 text-chart-2" />
</CardAction>
</CardHeader>
<CardContent>
<div className="text-3xl font-semibold tabular-nums">12,840</div>
<div className="mt-2 flex items-center gap-2">
<Badge status="success">+12.8%</Badge>
<span className="text-xs text-muted-foreground">from last month</span>
</div>
</CardContent>
<CardFooter>
<a
href="#analytics"
className="inline-flex items-center gap-1 rounded-sm text-sm font-medium text-primary outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50"
>
View analytics <ArrowUpRight aria-hidden="true" className="size-4 rtl:-scale-x-100" />
</a>
</CardFooter>
</Card>
)
}Installation
$ pnpm dlx shadcn@latest add @ballmac/cardCopy the source into your project.
components/ballmac/card.tsx// Ballmac UI: Card. https://ui.ballmac.com/components/card // Based on shadcn/ui Card (MIT, Copyright (c) 2023 shadcn), adding compact spacing and a restrained interactive surface. import * as React from "react" import { cn } from "@/lib/utils" type CardProps = React.ComponentProps<"div"> & { /** Compact spacing for dense dashboards. */ size?: "default" | "sm" /** Add a hover and focus treatment when the card contains a link or control. */ interactive?: boolean } function Card({ className, size = "default", interactive = false, ...props }: CardProps) { return ( <div data-slot="card" data-size={size} className={cn( "group/card bg-card text-card-foreground flex min-w-0 flex-col gap-5 rounded-xl border border-border py-5 shadow-sm transition-[border-color,box-shadow,transform] duration-200 data-[size=sm]:gap-3 data-[size=sm]:py-4", interactive && "hover:border-ring/50 hover:shadow-md focus-within:border-ring/50 motion-safe:hover:translate-y-[var(--bm-lift,-2px)] motion-reduce:transition-none", className, )} {...props} /> ) } function CardHeader({ className, ...props }: React.ComponentProps<"div">) { return ( <div data-slot="card-header" className={cn( "grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-start gap-x-3 gap-y-1 px-5 group-data-[size=sm]/card:px-4", className, )} {...props} /> ) } function CardTitle({ className, ...props }: React.ComponentProps<"div">) { return ( <div data-slot="card-title" className={cn("col-start-1 text-base font-semibold leading-6", className)} {...props} /> ) } function CardDescription({ className, ...props }: React.ComponentProps<"div">) { return ( <div data-slot="card-description" className={cn( "text-muted-foreground col-start-1 text-sm leading-relaxed", className, )} {...props} /> ) } function CardAction({ className, ...props }: React.ComponentProps<"div">) { return ( <div data-slot="card-action" className={cn("col-start-2 row-span-2 flex items-start gap-2", className)} {...props} /> ) } function CardContent({ className, ...props }: React.ComponentProps<"div">) { return ( <div data-slot="card-content" className={cn("min-w-0 px-5 group-data-[size=sm]/card:px-4", className)} {...props} /> ) } function CardFooter({ className, ...props }: React.ComponentProps<"div">) { return ( <div data-slot="card-footer" className={cn( "flex flex-wrap items-center gap-2 border-t border-border px-5 pt-4 group-data-[size=sm]/card:px-4", className, )} {...props} /> ) } export { Card, CardHeader, CardTitle, CardDescription, CardAction, CardContent, CardFooter, type CardProps, }Update the import paths to match your project setup.
Usage
import { Card, CardHeader, CardTitle, CardDescription, CardAction, CardContent, CardFooter } from "@/components/ballmac/card"The full example is in the Code tab above.
Examples
States and variants
import {
Card,
CardHeader,
CardTitle,
CardDescription,
CardContent,
} from "@/components/ballmac/card"
export default function CardStates() {
return (
<div className="grid w-full max-w-md gap-3 sm:grid-cols-2">
<Card size="sm">
<CardHeader>
<CardTitle>Active projects</CardTitle>
<CardDescription>Across all teams</CardDescription>
</CardHeader>
<CardContent>
<span className="text-2xl font-semibold tabular-nums">24</span>
</CardContent>
</Card>
<Card size="sm">
<CardHeader>
<CardTitle>Tasks due</CardTitle>
<CardDescription>In the next seven days</CardDescription>
</CardHeader>
<CardContent>
<span className="text-2xl font-semibold tabular-nums">8</span>
</CardContent>
</Card>
</div>
)
}API reference
| Prop | Type | Default |
|---|---|---|
sizeCompact spacing for dense dashboards. | "default" | "sm" | "default" |
interactiveAdd a hover and focus treatment when the card contains a link or control. | boolean | false |
Also accepts the standard attributes of its root element.
Accessibility
| Key | Action |
|---|---|
| Tab | reaches controls and links inside the card |
Quality scorecard
Every applicable check passes
Measured in Chromium 153.0.8010.12 on October 19, 2026, on version 1.0.1, across 2 examples.
Passed: Accessibility scan
No serious or critical issues in light and dark, on a phone and a desktop (axe-core 4.13.0, WCAG 2.1 AA and best-practice rules).
Passed: Small screens
No sideways scrolling at 360, 390 or 1280 px wide.
Passed: Reduced motion
No endless animation to begin with.
Passed: Right to left
Mirrors correctly in Arabic, Hebrew, Persian and Urdu layouts (0% of elements off the mirror, limit 15%).
Passed: Clean console
No console errors or React hydration errors while loading.
Passed: Keyboard
1 tab stop, each showing a visible change when it takes focus. 1 documented key.
Not applicable: Loading, empty and error
Does not show data or take submissions.
For information: Automated tests
No test file of its own yet.
For information: Footprint
0.9 KB of source (gzip) in 1 file. No extra npm packages.
Automated checks find a subset of problems and do not replace testing with a screen reader and a keyboard in your own app. What they miss.
Use with AI
A composable content surface with compact spacing, an action slot, and optional interactive feedback. With the shadcn MCP server set up (guide), ask your agent:
Add the Ballmac UI Card (@ballmac/card) to this project with the shadcn MCP, then use it where it fits.
Use it for
- Group a related set of content and actions
- Present a dashboard metric or settings panel
Not for
- Use an alert for status messages
Registry JSON: https://ui.ballmac.com/r/card.json
Credits
Based on shadcn/ui Card, adapted by Ballmac. Free to use in personal and commercial projects.
- npm
- None
- Registry
- shadcn/utils
Pairs well with
Button
A button with six variants, three sizes, a pill shape and a built-in loading state. buttonVariants() styles links the same way.
Badge
A small pill label in four variants with an optional status dot and success, warning and error tones. Style links with badgeVariants().
Bar List
A ranked list of bars with the name and number on top of the bar, so both stay readable at any width. Rows can be links or buttons, a long list folds to its top few, and every value is real text.
Chart
Theme-aware chart wrapper for Recharts with token colors, a styled tooltip and legend, a named figure with a screen-reader summary, and keyboard navigation.
Ballmac UI Pro
Need the whole screen, not one piece?
311 premium blocks (dashboards, settings, calendars, mail, shops, onboarding), a private shadcn registry and Figma tokens. Blocks that show data come with loading, empty and error states built in.
Not ready? Try three Pro blocks free
Leave your email and the blocks appear right here, ready to copy. Yours to use in any project.