[ Data Display ]
Card
A surface that groups related content and actions. Card is a flexible container; CardHeader, CardBody and CardFooter give it consistent spacing, a title area and an action row.
Import#
import { Card, CardHeader, CardBody, CardFooter } from 'reusify-ui';When to use#
- Grouping one topic: a project, a product, a user, a settings section.
- Building grids of similar items (dashboards, listings).
- Avoid nesting cards inside cards. Use a Divider or spacing instead.
Examples#
Anatomy#
CardHeader takes title, subtitle and an action slot on the right. CardFooter right-aligns its children.
Project Alpha
Updated 2 hours ago
<Card style={{ width: 340 }}>
<CardHeader
title="Project Alpha"
subtitle="Updated 2 hours ago"
action={<Badge color="success" dot>Live</Badge>}
/>
<CardBody>
A marketing site for the Alpha launch. 12 pages, 3 contributors.
</CardBody>
<CardFooter>
<Button variant="ghost" size="sm">Settings</Button>
<Button size="sm">Open</Button>
</CardFooter>
</Card>Variants#
outline (default) has a hairline border and a soft shadow. elevated lifts the card with a deeper layered shadow. hoverable adds a lift on hover, useful for clickable cards.
<Card><CardBody>Outline (default)</CardBody></Card>
<Card variant="elevated"><CardBody>Elevated</CardBody></Card>
<Card variant="elevated" hoverable><CardBody>Hover me</CardBody></Card>With media#
Card clips its content to the rounded corners, so images can go edge to edge.
Mountain retreat
Manali, India
<Card hoverable style={{ width: 300 }}>
<img src="/cover.jpg" alt="" style={{ height: 160, objectFit: 'cover' }} />
<CardHeader
title="Mountain retreat"
subtitle="Manali, India"
action={<Button variant="ghost" size="sm" aria-label="More"><FiMoreHorizontal /></Button>}
/>
<CardBody>3 nights · From ₹12,400</CardBody>
</Card>Used in designs#
Card in real layouts: these 3 designs use it. Open one to try it and copy the code.
API reference#
<Card />
Also accepts every <div> attribute.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | 'outline' | 'elevated' | 'outline' | Border-only or lifted with a shadow. |
hoverable | boolean | false | Lifts the card on hover. |
variant'outline''outline' | 'elevated'Border-only or lifted with a shadow.
hoverablefalsebooleanLifts the card on hover.
<CardHeader />
| Prop | Type | Default | Description |
|---|---|---|---|
title | ReactNode | - | Heading, rendered as <h3>. |
subtitle | ReactNode | - | Muted text under the title. |
action | ReactNode | - | Content aligned to the right (button, badge, menu). |
title-ReactNodeHeading, rendered as <h3>.
subtitle-ReactNodeMuted text under the title.
action-ReactNodeContent aligned to the right (button, badge, menu).
<CardBody />
A padded <div>. Accepts every <div> attribute.
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | - | Main content. |
children-ReactNodeMain content.
<CardFooter />
A <div> with a top border that right-aligns its children.
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | - | Usually action buttons. |
children-ReactNodeUsually action buttons.
Accessibility#
- Card is a plain <div>. If the whole card is clickable, put a real link or button inside it rather than an onClick on the div.
- CardHeader renders the title as an <h3>. Make sure that fits your page heading order.