Card
Web/MobileA flexible container with header, content, and footer.
Installation
pnpm dlx cubix-ui@latest add cardUsage
import { RocketIcon } from "lucide-react"
import { Button } from "@/components/cubix/button"
import { Card, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/cubix/card"
<Card className="w-full max-w-sm">
<CardHeader>
<CardTitle>انتشار نسخه جدید</CardTitle>
<CardDescription>تغییرات شما آماده انتشار است. با یک کلیک منتشرش کنید.</CardDescription>
</CardHeader>
<CardFooter>
<Button>
<RocketIcon data-icon="inline-start" />
انتشار
</Button>
</CardFooter>
</Card>
Composition
Build a card from these parts. CardAction is optional and sits at the inline-end of the header, so it moves to the left automatically in RTL layouts.
Card
├── CardHeader
│ ├── CardTitle
│ ├── CardDescription
│ └── CardAction
├── CardContent
└── CardFooterAccessibility
Card is a plain layout container with no implicit role. When a card represents a standalone region, render it as a section or pass role="region" with aria-labelledby pointing at the title. Wrap form cards in a form element so Enter submits and the fields are grouped for assistive tech.
Examples
With form
Cards pair with Cubix fields and buttons for short forms.
Login
A sign-in card with email and password fields. The header link uses CardAction.
With action
Use CardAction for a control at the inline-end of the header.
With icon
Compose the header with any element - an icon bubble draws attention to the title.
Size
Set size="sm" for tighter spacing and a smaller title.
Image
Place an image or media block as the first child. The card rounds the top edge, and pt-0 drops the top padding.
Spacing
Override --card-spacing on the root for a larger inset. Use gap-0 when the header uses a border so dividers sit flush.
API Reference
Note: Parts render data-slot attributes (card, card-header, card-title, card-description, card-action, card-content, card-footer) for targeting in tests and parent selectors. Use the same props on Base UI, React Aria, and Radix.
Card
| Prop | Type | Default | Description |
|---|---|---|---|
| size | "default" | "sm" | "default" | Spacing scale for the card. sm tightens padding, gaps, and title size. |
| className | string | - | Additional Tailwind classes merged with the component styles (last one wins). Use [--card-spacing:--spacing(n)] to override inset. |
| ...props | React.ComponentProps<'div'> | - | All native div attributes (role, id, aria-*, ...) are forwarded to the rendered element. |
CardHeader
Title, description, and optional action. With CardAction it becomes a two-column grid.
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | - | Additional Tailwind classes merged with the component styles (last one wins). |
| ...props | React.ComponentProps<'div'> | - | All native div attributes are forwarded to the rendered element. |
CardTitle
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | - | Additional Tailwind classes merged with the component styles (last one wins). |
| ...props | React.ComponentProps<'div'> | - | All native div attributes are forwarded to the rendered element. |
CardDescription
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | - | Additional Tailwind classes merged with the component styles (last one wins). |
| ...props | React.ComponentProps<'div'> | - | All native div attributes are forwarded to the rendered element. |
CardAction
Action slot at the inline-end of the header (button, badge, menu).
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | - | Additional Tailwind classes merged with the component styles (last one wins). |
| ...props | React.ComponentProps<'div'> | - | All native div attributes are forwarded to the rendered element. |
CardContent
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | - | Additional Tailwind classes merged with the component styles (last one wins). |
| ...props | React.ComponentProps<'div'> | - | All native div attributes are forwarded to the rendered element. |
CardFooter
Footer for primary and secondary actions.
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | - | Additional Tailwind classes merged with the component styles (last one wins). |
| ...props | React.ComponentProps<'div'> | - | All native div attributes are forwarded to the rendered element. |