Loading...
Loading...
Compare original and translation side by side
| Pattern | API / Approach | Key Points |
|---|---|---|
| Init project | | Auto-detects framework, configures CSS variables |
| Add component | | Copies source code into your project |
| Custom project | | Pick library (Radix/Base UI), style, theme, fonts |
| Check updates | | Shows upstream changes for your components |
| Search registry | | Browse and install from namespaced registries |
| Build registry | | Generate registry JSON from |
| Theme tokens | | oklch color values, dark mode via |
| Dark mode | | Swaps CSS variables under |
| Component variant | | Type-safe variant definitions |
| Polymorphic slot | | Merge props onto child element |
| Direct ref | | |
| Form (current) | | Replaces legacy |
| Form (legacy) | | Still works but no longer actively developed |
| Class merging | | Safely merge Tailwind classes without conflicts |
| 模式 | API / 实现方式 | 关键点 |
|---|---|---|
| 初始化项目 | | 自动检测框架,配置CSS变量 |
| 添加组件 | | 将源代码复制到你的项目中 |
| 自定义项目 | | 选择库(Radix/Base UI)、样式、主题、字体 |
| 检查更新 | | 显示组件的上游变更 |
| 搜索注册表 | | 浏览并安装命名空间注册表中的组件 |
| 构建注册表 | | 从 |
| 主题令牌 | | oklch颜色值,通过 |
| 暗黑模式 | | 在 |
| 组件变体 | | 类型安全的变体定义 |
| 多态插槽 | Radix提供的 | 将属性合并到子元素上 |
| 直接Ref | 将 | React 19中 |
| 表单(当前版本) | | 替代旧版 |
| 表单(旧版) | | 仍可使用但不再积极开发 |
| 类名合并 | 基于 | 安全合并Tailwind类名,避免冲突 |
| Mistake | Correct Pattern |
|---|---|
| Installing shadcn/ui as an npm dependency | Use the CLI ( |
Using | Pass |
| Using HSL values for color tokens | Use oklch format: |
Wrapping variables with | Reference CSS variables directly: |
Putting tokens directly in | Use |
Using legacy | Use |
| Skipping Zod validation in form components | Always pair forms with Zod schemas for type-safe validation |
Using | Use Radix or Base UI primitives for semantic HTML and accessibility |
Modifying components in | Components live in your source tree -- own and customize directly |
Using old CLI command | Use |
| 错误 | 正确做法 |
|---|---|
| 将shadcn/ui作为npm依赖安装 | 使用CLI( |
在React 19组件中使用 | 直接将 |
| 为颜色令牌使用HSL值 | 使用oklch格式: |
在工具类中用 | 直接引用CSS变量: |
将令牌直接放入 | 在 |
为新表单使用旧版 | 结合React Hook Form或TanStack Form使用 |
| 在表单组件中跳过Zod验证 | 始终将表单与Zod模式配对,实现类型安全验证 |
使用 | 使用Radix或Base UI原语以确保语义化HTML和可访问性 |
修改 | 组件位于你的源代码目录中——可直接拥有并自定义 |
使用旧版CLI命令 | 所有CLI操作均使用 |
ExploreTaskPlanTaskExploreTaskPlanTask