mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-07-01 08:34:12 +00:00
* feat: add base and radix docs * feat: transform code for display * fix * fix * fix * fix * fix * chore: remove claude files * fix * fix * fix * chore: run format:write * fix * feat: add more examples * fix * feat: add aspect-ratio * feat: add avatar * feat: add badge * feat: add breadcrumb * fix * feat: add button * fix * fix * fix * feat: add calendar and card * feat: add carousel * fix: chart * feat: add checkbox * feat: add collapsible * feat: add combobox * feat: add command * feat: add context menu * feat: add data-table dialog and drawer * feat: dropdown-menu * feat: add date-picker * feat: add empty * feat: add field and hover-card * fix: input * feat: add input * feat: add input-group * feat: add input-otp * feat: add item * feat: add kbd and label * feat: add menubar * feat: add native-select * feat: add more components * feat: more components * feat: more components * feat: add skeleton, slider and sonner * feat: add spinner and switch * feat: add more components * fix: tabs * fix: tabs * feat: add docs for sidebar * fix * fix * fi * docs: update * fix: create page * fix * fix * chore: add changelog * fix
160 lines
3.1 KiB
Plaintext
160 lines
3.1 KiB
Plaintext
---
|
|
title: Card
|
|
description: Displays a card with header, content, and footer.
|
|
base: base
|
|
component: true
|
|
---
|
|
|
|
<ComponentPreview
|
|
name="card-demo"
|
|
styleName="base-nova"
|
|
previewClassName="h-[30rem]"
|
|
/>
|
|
|
|
## Installation
|
|
|
|
<CodeTabs>
|
|
|
|
<TabsList>
|
|
<TabsTrigger value="cli">Command</TabsTrigger>
|
|
<TabsTrigger value="manual">Manual</TabsTrigger>
|
|
</TabsList>
|
|
<TabsContent value="cli">
|
|
|
|
```bash
|
|
npx shadcn@latest add card
|
|
```
|
|
|
|
</TabsContent>
|
|
|
|
<TabsContent value="manual">
|
|
|
|
<Steps className="mb-0 pt-2">
|
|
|
|
<Step>Copy and paste the following code into your project.</Step>
|
|
|
|
<ComponentSource
|
|
name="card"
|
|
title="components/ui/card.tsx"
|
|
styleName="base-nova"
|
|
/>
|
|
|
|
<Step>Update the import paths to match your project setup.</Step>
|
|
|
|
</Steps>
|
|
|
|
</TabsContent>
|
|
|
|
</CodeTabs>
|
|
|
|
## Usage
|
|
|
|
```tsx showLineNumbers
|
|
import {
|
|
Card,
|
|
CardAction,
|
|
CardContent,
|
|
CardDescription,
|
|
CardFooter,
|
|
CardHeader,
|
|
CardTitle,
|
|
} from "@/components/ui/card"
|
|
```
|
|
|
|
```tsx showLineNumbers
|
|
<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
|
|
|
|
### Size
|
|
|
|
Use the `size="sm"` prop to set the size of the card to small. The small size variant uses smaller spacing.
|
|
|
|
<ComponentPreview
|
|
styleName="base-nova"
|
|
name="card-small"
|
|
previewClassName="h-96"
|
|
/>
|
|
|
|
### Image
|
|
|
|
Add an image before the card header to create a card with an image.
|
|
|
|
<ComponentPreview
|
|
styleName="base-nova"
|
|
name="card-image"
|
|
previewClassName="h-[32rem]"
|
|
/>
|
|
|
|
## 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` | - |
|