Docs
常见问题
常见问题
关于运行注册表的常见问题解答。
常见问题
复杂组件是什么样的?
以下是一个复杂组件的示例,它安装一个页面、两个组件、一个钩子、一个格式化日期的工具和一个配置文件。
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "hello-world",
"title": "你好,世界",
"type": "registry:block",
"description": "一个复杂的你好,世界组件",
"files": [
{
"path": "registry/new-york/hello-world/page.tsx",
"type": "registry:page",
"target": "app/hello/page.tsx"
},
{
"path": "registry/new-york/hello-world/components/hello-world.tsx",
"type": "registry:component"
},
{
"path": "registry/new-york/hello-world/components/formatted-message.tsx",
"type": "registry:component"
},
{
"path": "registry/new-york/hello-world/hooks/use-hello.ts",
"type": "registry:hook"
},
{
"path": "registry/new-york/hello-world/lib/format-date.ts",
"type": "registry:utils"
},
{
"path": "registry/new-york/hello-world/hello.config.ts",
"type": "registry:file",
"target": "~/hello.config.ts"
}
]
}
如何添加新的 Tailwind 颜色?
要添加新颜色,您需要将其添加到 cssVars
下的 light
和 dark
键中。
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "hello-world",
"title": "Hello World",
"type": "registry:block",
"description": "一个复杂的你好,世界组件",
"files": [
// ...
],
"cssVars": {
"light": {
"brand-background": "20 14.3% 4.1%",
"brand-accent": "20 14.3% 4.1%"
},
"dark": {
"brand-background": "20 14.3% 4.1%",
"brand-accent": "20 14.3% 4.1%"
}
}
}
CLI 会更新项目的 CSS 文件。更新后,这些新颜色将可以作为实用类使用:bg-brand
和 text-brand-accent
。
如何添加或重写 Tailwind 主题变量?
要添加或重写主题变量,您需要将其添加到 cssVars.theme
下的键中。
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "hello-world",
"title": "Hello World",
"type": "registry:block",
"description": "一个复杂的你好,世界组件",
"files": [
// ...
],
"cssVars": {
"theme": {
"text-base": "3rem",
"ease-in-out": "cubic-bezier(0.4, 0, 0.2, 1)",
"font-heading": "Poppins, sans-serif"
}
}
}