98.0k

索引

PreviousNext

开源注册表索引

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

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

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

添加注册表

你可以通过提交 PR 来向索引中添加注册表,只需将其添加到 registries.json 文件中。

下面是向索引中添加注册表的示例:

registries.json
{
  "@acme": "https://registry.acme.com/r/{name}.json",
  "@example": "https://example.com/r/{name}"
}

要求

  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"
        }
      ]
    }
    }
  ]
}

验证

shadcn/ui 项目的根目录,你可以运行以下命令来验证 registries.json 文件。

pnpm validate:registries

该命令会验证 registries.json 文件并输出任何错误。

提交 PR 后,它将由团队进行验证和审核。