106k
New

添加注册表

开源注册表索引

开源注册表索引是一个包含所有可开箱即用的开源注册表的列表。

当你运行 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 创建一个拉取请求

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

要求

  1. 注册表必须是开源的且公开可访问。
  2. 注册表必须是符合 registry schema specification 的有效 JSON 文件。
  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": "登录表单",
      "description": "一个登录表单组件。",
      "files": [
        {
          "path": "registry/new-york/auth/login-form.tsx",
          "type": "registry:component"
        }
      ]
    },
    {
      "name": "example-login-form",
      "type": "registry:component",
      "title": "登录表单示例",
      "description": "展示如何使用登录表单组件的示例。",
      "files": [
        {
          "path": "registry/new-york/examples/example-login-form.tsx",
          "type": "registry:component"
        }
      ]
    }
  ]
}