组件
开源注册表索引是所有可直接使用的开源注册表的列表。
当你运行 shadcn add
或 shadcn search
时,CLI 会自动在注册表索引中查找你正在寻找的注册表,并将其添加到你的 components.json
文件中。
你可以在 https://ui.shadcn.org.cn/r/registries.json 查看完整列表。
添加注册表
你可以通过提交 PR 将注册表添加到索引中,方法是将其添加到 registries.json 文件。
这是一个将注册表添加到索引的示例
{
"@acme": "https://registry.acme.com/r/{name}.json",
"@example": "https://example.com/r/{name}"
}
要求
- 该注册表必须是开源的并可公开访问。
- 该注册表必须是符合 注册表模式规范 的有效 JSON 文件。
- 注册表应为扁平注册表,不包含嵌套项,即
/registry.json
和/component-name.json
文件应位于注册表的根目录。 - 如果存在
files
数组,则不得包含content
属性。
这是一个有效注册表的示例
{
"$schema": "https://ui.shadcn.org.cn/schema/registry.json",
"name": "acme",
"homepage": "https://acme.com",
"items": [
{
"name": "login-form",
"type": "registry:component",
"title": "Login Form",
"description": "A login form component.",
"files": [
{
"path": "registry/new-york/auth/login-form.tsx",
"type": "registry:component"
}
]
},
{
"name": "example-login-form",
"type": "registry:component",
"title": "Example Login Form",
"description": "An example showing how to use the login form component.",
"files": [
{
"path": "registry/new-york/examples/example-login-form.tsx",
"type": "registry:component"
}
]
}
}
]
}
验证
在 shadcn/ui
项目的根目录,你可以运行以下命令来验证 registries.json
文件。
pnpm validate:registries
这将验证 registries.json 文件并输出任何错误。
提交 PR 后,团队将对其进行验证和审查。