109k

添加 Registry

开源 Registry 索引

开源 Registry 索引是一份清单,列出了所有可以开箱即用的开源 Registry。

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

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

添加 Registry

  1. 将你的 Registry 添加到 apps/v4/registry/directory.json
  2. 运行 pnpm registry:build 以更新 registries.json 文件。
  3. https://github.com/shadcn-ui/ui 提交拉取请求(Pull Request)

提交请求后,团队将对你的请求进行验证和审核。

要求

  1. 该 Registry 必须是开源且可公开访问的。
  2. 该 Registry 必须是一个符合 Registry 模式规范 的有效 JSON 文件。
  3. Registry 应为扁平化结构,不包含嵌套项,即 /registry.json/component-name.json 文件应位于 Registry 的根目录下。
  4. 如果存在 files 数组,则不得包含 content 属性。

以下是一个有效的 Registry 示例

registry.json
{
  "$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"
        }
      ]
    }
    }
  ]
}