- 手风琴
- 警报
- 警报对话框
- 纵横比
- 头像
- 徽章
- 面包屑
- 按钮
- 按钮组
- 日历
- 卡片
- 轮播
- 图表
- 复选框
- 可折叠
- 组合框
- 命令
- 上下文菜单
- 数据表格
- 日期选择器
- 对话框
- 方向
- 抽屉
- 下拉菜单
- 空
- 字段
- 悬停卡
- 输入
- 输入组
- 输入 OTP
- 条目
- 键盘
- 标签
- 菜单栏
- 原生选择
- 导航菜单
- 分页
- 弹出窗口
- 进度
- 单选按钮组
- 可调整大小
- 滚动区域
- 选择
- 分隔符
- 工作表
- 侧边栏
- 骨架
- 滑块
- Sonner
- 旋转器
- 切换
- 表格
- 标签
- 文本区域
- Toast
- 切换
- 切换组
- 工具提示
- 排版
- 手风琴
- 警报
- 警报对话框
- 纵横比
- 头像
- 徽章
- 面包屑
- 按钮
- 按钮组
- 日历
- 卡片
- 轮播
- 图表
- 复选框
- 可折叠
- 组合框
- 命令
- 上下文菜单
- 数据表格
- 日期选择器
- 对话框
- 方向
- 抽屉
- 下拉菜单
- 空
- 字段
- 悬停卡
- 输入
- 输入组
- 输入 OTP
- 条目
- 键盘
- 标签
- 菜单栏
- 原生选择
- 导航菜单
- 分页
- 弹出窗口
- 进度
- 单选按钮组
- 可调整大小
- 滚动区域
- 选择
- 分隔符
- 工作表
- 侧边栏
- 骨架
- 滑块
- Sonner
- 旋转器
- 切换
- 表格
- 标签
- 文本区域
- Toast
- 切换
- 切换组
- 工具提示
- 排版
import { Button } from "@/components/ui/button"
import {
Card,安装
🌐 Installation
pnpm dlx shadcn@latest add card
用法
🌐 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
大小
🌐 Size
使用 size="sm" 属性将卡片的大小设置为小。小尺寸版本使用更小的间距。
🌐 Use the size="sm" prop to set the size of the card to small. The small size variant uses smaller spacing.
- Choose a schedule (daily, or weekly).
- Send to channels or specific teammates.
- Include charts, tables, and key metrics.
import { Button } from "@/components/ui/button"
import {
Card,图片
🌐 Image
在卡片标题前添加一张图片以创建带图片的卡片。
🌐 Add an image before the card header to create a card with an image.
import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import {从右到左
🌐 RTL
要在 shadcn/ui 中启用 RTL 支持,请参阅 RTL 配置指南。
🌐 To enable RTL support in shadcn/ui, see the RTL configuration guide.
"use client"
import * as React from "react"API参考
🌐 API Reference
卡片
🌐 Card
Card 组件是卡片内容的根容器。
🌐 The Card component is the root container for card content.
| 属性 | 类型 | 默认值 |
|---|---|---|
size | "default" | "sm" | "default" |
className | string | - |
CardHeader
CardHeader 组件用于显示标题、描述和可选操作。
🌐 The CardHeader component is used for a title, description, and optional action.
| 属性 | 类型 | 默认值 |
|---|---|---|
className | string | - |
CardTitle
CardTitle 组件用于卡片标题。
🌐 The CardTitle component is used for the card title.
| 属性 | 类型 | 默认值 |
|---|---|---|
className | string | - |
CardDescription
CardDescription 组件用于标题下的辅助文本。
🌐 The CardDescription component is used for helper text under the title.
| 属性 | 类型 | 默认值 |
|---|---|---|
className | string | - |
CardAction
CardAction 组件将内容放置在头部的右上角(例如,一个按钮或徽章)。
🌐 The CardAction component places content in the top-right of the header (for example, a button or a badge).
| 属性 | 类型 | 默认值 |
|---|---|---|
className | string | - |
CardContent
CardContent 组件用于主卡片主体。
🌐 The CardContent component is used for the main card body.
| 属性 | 类型 | 默认值 |
|---|---|---|
className | string | - |
CardFooter
CardFooter 组件用于卡片底部的操作和次要内容。
🌐 The CardFooter component is used for actions and secondary content at the bottom of the card.
| 属性 | 类型 | 默认值 |
|---|---|---|
className | string | - |