Card
A versatile container for grouping related content and actions with slot-based composition.
Basic
A versatile container for grouping related content and actions.
Card Title
Card subtitle text
This is the main content area of the card. It can contain any content you need.
Installation
Install the component via the CLI in one command.
npx @work-rjkashyap/unified-ui add cardpnpm dlx @work-rjkashyap/unified-ui add cardnpx @work-rjkashyap/unified-ui add cardbunx @work-rjkashyap/unified-ui add cardIf you haven't initialized your project yet, run npx @work-rjkashyap/unified-ui init first. See the CLI docs for details.
Or install the full package
Use this approach if you prefer to install the entire design system as a dependency instead of copying individual components.
npm install @work-rjkashyap/unified-uipnpm add @work-rjkashyap/unified-uiyarn add @work-rjkashyap/unified-uibun add @work-rjkashyap/unified-uiAnatomy
import {
Card,
CardHeader,
CardBody,
CardFooter,
Button,
Badge,
} from "@work-rjkashyap/unified-ui";Variants
Default
The standard card with a subtle background and border.
Default Card
Subtle background with a standard border. Blends into the page naturally.
Outlined
Transparent background with a stronger border. Use when the card sits on a colored or complex background.
Outlined Card
Transparent background with a stronger border for contrast.
Elevated
Raised card with shadow to draw attention or lift content above the page surface.
Elevated Card
Uses shadow to create depth and visual prominence.
Interactive
Clickable card with hover lift animation, focus ring, and cursor pointer. Ideal for navigation cards.
All Variants Side by Side
Slot Composition
Cards use a slot-based pattern with CardHeader, CardBody, and CardFooter sub-components. Each slot automatically inherits the card's padding setting via React context.
Full Composition
Project Settings
Manage your project configuration
Update your project name, description, and visibility settings. Changes are saved automatically.
Body Only
A simple card with only a body slot. No header or footer needed.
Without Borders on Slots
No Border Header
The header and footer borders can be removed independently.
Padding
The padding prop controls the internal spacing of all slot sub-components. Padding is applied to the slots, not the card root, which allows edge-to-edge images or content.
Compact (p-4)
Default padding for dense UIs and smaller cards.
Comfortable (p-6)
More generous padding for prominent content cards.
Footer Alignment
The CardFooter supports horizontal alignment of its content via the align prop.
align="end" (default)
align="between"
align="start"
Full Width
This card stretches to fill its container width using the fullWidth prop.
Polymorphic Rendering
The Card root accepts an as prop for polymorphic rendering. This is especially useful with the interactive variant.
{
/* As a link */
}
<Card variant="interactive" as="a" href="/project/123">
<CardBody>Click to view project</CardBody>
</Card>;
{
/* As a Next.js Link */
}
import Link from "next/link";
<Card variant="interactive" as={Link} href="/project/123">
<CardBody>Navigate to project</CardBody>
</Card>;
{
/* As a button */
}
<Card variant="interactive" as="button" onClick={handleClick}>
<CardBody>Clickable card</CardBody>
</Card>;Props
Card
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "default" | "outlined" | "elevated" | "interactive" | "default" | Visual variant of the card. |
padding | "compact" | "comfortable" | "compact" | Padding scale for slot sub-components. |
fullWidth | boolean | false | Whether the card stretches to fill its container. |
as | ElementType | "div" | The HTML element or component to render as. |
className | string | — | Additional CSS classes. |
CardHeader
| Prop | Type | Default | Description |
|---|---|---|---|
bordered | boolean | true | Whether to show a bottom border separator. |
className | string | — | Additional CSS classes. |
CardBody
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Additional CSS classes. |
CardFooter
| Prop | Type | Default | Description |
|---|---|---|---|
bordered | boolean | true | Whether to show a top border separator. |
align | "start" | "center" | "end" | "between" | "end" | Horizontal alignment of footer content. |
className | string | — | Additional CSS classes. |
Accessibility
- Interactive variant includes a visible focus ring for keyboard navigation.
- When used as a link (
as="a"), the card supports standard link semantics. - Content within cards should maintain proper heading hierarchy — don't skip from
h2toh4. - The interactive variant removes text decoration for anchor usage.