111k

Add a Registry

开源注册库索引。

开源注册库索引列出了所有开箱即用、可供使用的开源注册库。

当你运行 shadcn addshadcn search 时,CLI 会自动在注册库索引中查找你需要的注册库,并将其添加到你的 components.json 文件中。

你可以在 https://ui.shadcn.com/r/registries.json 查看完整列表。

添加注册库

  1. 将你的注册库添加到 apps/v4/registry/directory.json
  2. 运行 pnpm registry:build 来更新 registries.json 文件。
  3. https://github.com/shadcn-ui/ui 提交一个 pull request

当你提交请求后,团队会对其进行校验和审核。

要求

  1. 注册库必须是开源且可公开访问的。
  2. 注册库必须是一个有效的 JSON 文件,并符合 registry schema 规范
  3. 注册库应当是扁平结构,不包含嵌套条目,也就是说,/registry.json/component-name.json 文件应该位于注册库根目录。
  4. 如果存在 files 数组,则其中不得包含 content 属性。

下面是一个有效注册库的示例:

registry.json
{
  "$schema": "https://ui.shadcn.com/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"
        }
      ]
    }
  ]
}