shadcn-registries

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

shadcn Registries

shadcn 注册表

Agent Workflow (MANDATORY)

Agent 工作流程(强制要求)

Before registry configuration, use
TeamCreate
:
  1. fuse-ai-pilot:explore-codebase - Find existing components.json
  2. fuse-ai-pilot:research-expert - Verify latest CLI options via Context7
After: Run fuse-ai-pilot:sniper for validation.

在配置注册表之前,请使用
TeamCreate
  1. fuse-ai-pilot:explore-codebase - 查找现有的components.json文件
  2. fuse-ai-pilot:research-expert - 通过Context7验证最新的CLI选项
完成后:运行fuse-ai-pilot:sniper进行验证。

Overview

概述

RegistryPrimitivesStyle
@shadcn
(default)
Radix UI
new-york
,
default
@basecn
Base UI
base-vega
CustomAnyCustom

注册表基础组件样式
@shadcn
(默认)
Radix UI
new-york
,
default
@basecn
Base UI
base-vega
自定义任意自定义

Critical Rules

重要规则

  1. ALWAYS detect PM before any CLI command (use {runner})
  2. ALWAYS consult MCP before adding components
  3. NEVER mix registries in same project
  4. KEEP components.json in sync with actual primitive
  5. USE CLI for adding components, never manual copy

  1. 始终在执行任何CLI命令前检测包管理器(使用{runner})
  2. 始终在添加组件前咨询MCP
  3. 切勿在同一项目中混合使用不同注册表
  4. 保持components.json与实际基础组件同步
  5. 使用CLI添加组件,切勿手动复制

Architecture

项目结构

project/
├── components.json         # shadcn/ui configuration
├── components/ui/          # Generated components
└── lib/utils.ts            # Utility functions (cn)
-> See registry-setup.md for complete setup

project/
├── components.json         # shadcn/ui 配置文件
├── components/ui/          # 生成的组件
└── lib/utils.ts            # 工具函数(cn)
-> 完整设置请参见registry-setup.md

CLI Commands

CLI 命令

ALWAYS use detected package manager (run
shadcn-detection
first).
{runner}
=
bunx
|
npx
|
pnpm dlx
|
yarn dlx
bash
undefined
始终使用检测到的包管理器(先运行
shadcn-detection
)。
{runner}
=
bunx
|
npx
|
pnpm dlx
|
yarn dlx
bash
undefined

Initialize

初始化

{runner} shadcn@latest init {runner} shadcn@latest init --style new-york
{runner} shadcn@latest init {runner} shadcn@latest init --style new-york

Add components (default registry = Radix)

添加组件(默认注册表 = Radix)

{runner} shadcn@latest add button dialog select
{runner} shadcn@latest add button dialog select

Add from Base UI registry

从Base UI注册表添加组件

{runner} shadcn@latest add --registry=basecn button dialog
undefined
{runner} shadcn@latest add --registry=basecn button dialog
undefined

MCP (MANDATORY)

MCP(强制要求)

mcp__shadcn__search_items_in_registries -> find component
mcp__shadcn__get_add_command_for_items  -> get exact CLI command

mcp__shadcn__search_items_in_registries -> 查找组件
mcp__shadcn__get_add_command_for_items  -> 获取精确的CLI命令

components.json Structure

components.json 结构

json
{
  "$schema": "https://ui.shadcn.com/schema.json",
  "style": "new-york",
  "tailwind": { "config": "tailwind.config.ts", "css": "app/globals.css" },
  "aliases": { "components": "@/components", "utils": "@/lib/utils" }
}
-> See registry-config.md for full schema

json
{
  "$schema": "https://ui.shadcn.com/schema.json",
  "style": "new-york",
  "tailwind": { "config": "tailwind.config.ts", "css": "app/globals.css" },
  "aliases": { "components": "@/components", "utils": "@/lib/utils" }
}
-> 完整Schema请参见registry-config.md

Reference Guide

参考指南

Concepts

概念

TopicReferenceWhen to Consult
Registry Configregistry-config.mdSetting up components.json
主题参考文档查阅时机
注册表配置registry-config.md设置components.json时

Templates

模板

TemplateWhen to Use
registry-setup.mdInitial project setup

模板使用场景
registry-setup.md项目初始设置时

Best Practices

最佳实践

DO

建议

  • Use MCP to check registry before adding
  • Keep components.json in sync with actual primitive
  • Use CLI for adding, not manual copy
  • 添加组件前使用MCP检查注册表
  • 保持components.json与实际基础组件同步
  • 使用CLI添加组件,而非手动复制

DON'T

禁忌

  • Mix registries in same project
  • Edit component internals without checking registry source
  • Skip components.json configuration
  • 在同一项目中混合使用不同注册表
  • 未检查注册表源的情况下编辑组件内部代码
  • 跳过components.json配置