Components
- 手风琴
- 提示
- 警告对话框
- 宽高比
- 头像
- 徽章
- 面包屑导航
- 按钮
- 按钮组
- 日历 Calendar
- 卡片
- 轮播图
- 图表 Chart
- 复选框
- 折叠面板
- 组合框
- 命令
- 上下文菜单
- 数据表格 Data Table
- 日期选择器 Date Picker
- 对话框 Dialog
- 方向
- 抽屉
- 下拉菜单
- 空状态
- 字段
- 悬停卡片
- 输入
- 输入组
- Input OTP
- 项目
- Kbd
- 标签
- 菜单栏
- 原生选择框
- 导航菜单 Navigation Menu
- 分页
- 弹出框
- 进度 Progress
- 单选框组
- 可调整大小
- 滚动区域 Scroll Area
- 选择框
- 分隔符 Separator
- 侧边栏 Sheet
- 侧边栏 Sidebar
- 骨架屏
- 滑块
- Sonner
- 加载指示器 Spinner
- 开关
- 表格
- 标签页 Tabs
- 文本域
- 吐司
- 切换按钮 Toggle
- 切换组
- 提示 Tooltip
- 排版
registry.json 架构用于定义你自定义的组件注册表。
{
"$schema": "https://ui.shadcn.com/schema/registry.json",
"name": "shadcn",
"homepage": "https://ui.shadcn.com",
"items": [
{
"name": "hello-world",
"type": "registry:block",
"title": "Hello World",
"description": "一个简单的 hello world 组件。",
"registryDependencies": [
"button",
"@acme/input-form",
"https://example.com/r/foo"
],
"dependencies": ["is-even@3.0.0", "motion"],
"files": [
{
"path": "registry/default/hello-world/hello-world.tsx",
"type": "registry:component"
}
]
}
]
}你也可以使用 include 将一个大型注册表组织到多个 registry.json 文件中。
{
"$schema": "https://ui.shadcn.com/schema/registry.json",
"name": "acme",
"homepage": "https://acme.com",
"include": [
"components/ui/registry.json",
"hooks/registry.json"
]
}公共 GitHub 仓库使用相同的源注册表格式。CLI 读取根目录下的 registry.json,解析 include,并从仓库中安装文件。更多信息请参阅 GitHub registry 文档。
定义#
你可以在这里查看 registry.json 的 JSON 架构。
$schema#
$schema 属性用于指定 registry.json 文件的架构。
{
"$schema": "https://ui.shadcn.com/schema/registry.json"
}name#
name 属性用于指定你的注册表的名称。该名称用于数据属性及其他元数据。
{
"name": "acme"
}homepage#
注册表的主页地址。该地址用于数据属性及其他元数据。
{
"homepage": "https://acme.com"
}include#
include 属性用于将其他 registry.json 文件组合成一个注册表。
{
"include": [
"components/ui/registry.json",
"hooks/registry.json"
]
}每个 include 路径必须是指向明确 registry.json 文件的相对路径。
不支持文件夹简写。
{
"include": [
"components/ui/registry.json"
]
}包含的 registry.json 文件可以省略 name 和 homepage。这些字段
仅在根 registry.json 中是必需的。
{
"$schema": "https://ui.shadcn.com/schema/registry.json",
"items": [
{
"name": "button",
"type": "registry:ui",
"files": [
{
"path": "button.tsx",
"type": "registry:ui"
}
]
}
]
}当 shadcn build 解析 include 时,项目文件路径会相对于声明该项目的
registry.json 文件读取。生成的注册表输出会被展平,并且不包含 include。
注册表项目名称在解析后的注册表中必须唯一,包括所有 包含的文件。
items#
注册表中的 items。每个 item 必须实现registry-item 架构规范。
{
"items": [
{
"name": "hello-world",
"type": "registry:block",
"title": "Hello World",
"description": "一个简单的 hello world 组件。",
"registryDependencies": [
"button",
"@acme/input-form",
"https://example.com/r/foo"
],
"dependencies": ["is-even@3.0.0", "motion"],
"files": [
{
"path": "registry/default/hello-world/hello-world.tsx",
"type": "registry:component"
}
]
}
]
}根 registry.json 必须至少定义 items 或 include 其中之一。如果
省略 items,其默认值为空数组。
有关更多信息,请参阅registry-item 架构文档。