114k

registry.json

用于运行你自己的组件注册库的 schema。

registry.json schema 用于定义你的自定义注册库。

registry.json
{
  "$schema": "https://ui.shadcn.com/schema/registry.json",
  "name": "shadcn",
  "homepage": "https://ui.shadcn.com",
  "items": [
    {
      "name": "hello-world",
      "type": "registry:block",
      "title": "Hello World",
      "description": "A simple hello world component.",
      "registryDependencies": [
        "button",
        "@acme/input-form",
        "https://example.com/r/foo"
      ],
      "dependencies": ["is-even@3.0.0", "motion"],
      "files": [
        {
          "path": "registry/new-york/hello-world/hello-world.tsx",
          "type": "registry:component"
        }
      ]
    }
  ]
}

定义

你可以在 这里 查看 registry.json 的 JSON Schema。

$schema

$schema 属性用于指定 registry.json 文件所使用的 schema。

registry.json
{
  "$schema": "https://ui.shadcn.com/schema/registry.json"
}

name

name 属性用于指定你的注册库名称。它会用于数据属性和其他元数据。

registry.json
{
  "name": "acme"
}

homepage

注册库的主页。它会用于数据属性和其他元数据。

registry.json
{
  "homepage": "https://acme.com"
}

items

注册库中的 items。每个条目都必须实现 registry-item schema 规范

registry.json
{
  "items": [
    {
      "name": "hello-world",
      "type": "registry:block",
      "title": "Hello World",
      "description": "A simple hello world component.",
      "registryDependencies": [
        "button",
        "@acme/input-form",
        "https://example.com/r/foo"
      ],
      "dependencies": ["is-even@3.0.0", "motion"],
      "files": [
        {
          "path": "registry/new-york/hello-world/hello-world.tsx",
          "type": "registry:component"
        }
      ]
    }
  ]
}

更多信息请参阅 registry-item schema 文档