Getting Started
Components52
- Accordion
- Alert
- Alert Dialog
- Attachment
- Badge
- Breadcrumb
- Bubble
- Button
- Button Group
- Calendar
- Card
- Checkbox
- Collapsible
- Command
- Context Menu
- Data Table
- Dialog
- Drawer
- Dropdown Menu
- Empty
- Field
- Hover Card
- Input
- Input Group
- Item
- Kbd
- Label
- Marker
- Menubar
- Message
- Message Scroller
- Pagination
- Popover
- Progress
- Questionnaire
- Radio Group
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toggle
- Toggle Group
- Tooltip
Data sync
Products, orders and customers update every hour.
Connected
import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import {
Card,
CardAction,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "@/components/ui/card"
import { Field, FieldLabel } from "@/components/ui/field"
import { Input } from "@/components/ui/input"
export function CardDemo() {
return (
<Card className="w-full max-w-sm">
<CardHeader>
<CardTitle>Data sync</CardTitle>
<CardDescription>
Products, orders and customers update every hour.
</CardDescription>
<CardAction>
<Badge className="bg-success/15 text-success">Connected</Badge>
</CardAction>
</CardHeader>
<CardContent>
<Field>
<FieldLabel htmlFor="card-store">Store URL</FieldLabel>
<Input id="card-store" defaultValue="acme.myshopify.com" />
</Field>
</CardContent>
<CardFooter className="justify-end gap-2">
<Button variant="outline">Disconnect</Button>
<Button>Sync now</Button>
</CardFooter>
</Card>
)
}Installation#
pnpm dlx shadcn@latest add https://ui.ikramhasan.com/r/card.json
Usage#
import {
Card,
CardAction,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "@/components/ui/card"<Card>
<CardHeader>
<CardTitle>Card Title</CardTitle>
<CardDescription>Card Description</CardDescription>
<CardAction>Card Action</CardAction>
</CardHeader>
<CardContent>
<p>Card Content</p>
</CardContent>
<CardFooter>
<p>Card Footer</p>
</CardFooter>
</Card>Examples#
Action and small size#
Getting started
1 of 5 steps done
import { XIcon } from "lucide-react"
import { Button } from "@/components/ui/button"
import {
Card,
CardAction,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card"
export function CardSmall() {
return (
<Card size="sm" className="w-full max-w-sm">
<CardHeader>
<CardTitle>Getting started</CardTitle>
<CardDescription>1 of 5 steps done</CardDescription>
<CardAction>
<Button variant="ghost" size="icon-sm" aria-label="Dismiss">
<XIcon />
</Button>
</CardAction>
</CardHeader>
</Card>
)
}Action cards#
import { PenLineIcon, SearchIcon, SparklesIcon } from "lucide-react"
import {
Card,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card"
export function CardActionCards() {
return (
<div className="grid w-full gap-4 sm:grid-cols-3">
{actions.map(({ icon: Icon, title, description }) => (
<a
key={title}
href="#card"
className="group/action rounded-2xl outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
>
<Card className="h-full transition-[box-shadow] group-hover/action:shadow-[0_1px_2px_rgb(0_0_0/0.04),0_4px_12px_rgb(0_0_0/0.05)] group-hover/action:ring-input">
<CardHeader>
<Icon className="mb-7 size-5 text-muted-foreground" />
<CardTitle>{title}</CardTitle>
<CardDescription>{description}</CardDescription>
</CardHeader>
</Card>
</a>
))}
</div>
)
}
const actions = [
{
icon: PenLineIcon,
title: "Create",
description: "Draft a post or a product page.",
},
{
icon: SearchIcon,
title: "Find",
description: "Look up orders and customers.",
},
{
icon: SparklesIcon,
title: "Research",
description: "Compare competitors' pricing.",
},
]API Reference#
Card#
The Card component is the root container for card content.
| Prop | Type | Default |
|---|---|---|
size | "default" | "sm" | "default" |
className | string | - |
CardHeader#
The CardHeader component is used for a title, description, and optional action.
| Prop | Type | Default |
|---|---|---|
className | string | - |
CardTitle#
The CardTitle component is used for the card title.
| Prop | Type | Default |
|---|---|---|
className | string | - |
CardDescription#
The CardDescription component is used for helper text under the title.
| Prop | Type | Default |
|---|---|---|
className | string | - |
CardAction#
The CardAction component places content in the top-right of the header (for example, a button or a badge).
| Prop | Type | Default |
|---|---|---|
className | string | - |
CardContent#
The CardContent component is used for the main card body.
| Prop | Type | Default |
|---|---|---|
className | string | - |
CardFooter#
The CardFooter component is used for actions and secondary content at the bottom of the card.
| Prop | Type | Default |
|---|---|---|
className | string | - |