1- # ObjectUI vs Shadcn: 组件对照表
1+ # ObjectUI vs Shadcn: Component Mapping Guide
22
3- ** 快速参考 ** : 了解ObjectUI渲染器与Shadcn UI组件的关系
3+ ** Quick Reference ** : Understanding the relationship between ObjectUI Renderer and Shadcn UI components
44
55---
66
7- ## 概念区分
7+ ## Conceptual Distinction
88
9- ### Shadcn UI组件
10- - 📦 ** 纯UI组件库 **
11- - 🎨 基于Radix UI + Tailwind CSS
12- - 💻 需要编写React代码
13- - 🔧 通过Props控制
9+ ### Shadcn UI Components
10+ - 📦 ** Pure UI Component Library **
11+ - 🎨 Built on Radix UI + Tailwind CSS
12+ - 💻 Requires writing React code
13+ - 🔧 Controlled via Props
1414
15- ### ObjectUI渲染器
16- - 🔄 ** Schema解释器 **
17- - 📋 基于JSON配置驱动
18- - 🚀 零代码即可使用
19- - 🔗 自动数据绑定和验证
15+ ### ObjectUI Renderer
16+ - 🔄 ** Schema Interpreter **
17+ - 📋 JSON configuration-driven
18+ - 🚀 Zero-code usage
19+ - 🔗 Automatic data binding and validation
2020
2121---
2222
23- ## 一对一映射关系
23+ ## One-to-One Mapping
2424
25- | Shadcn UI | ObjectUI渲染器 | 增强功能 |
25+ | Shadcn UI | ObjectUI Renderer | Enhanced Features |
2626| -----------| ---------------| ---------|
27- | ` <Input /> ` | ` { type: "input" } ` | ✅ 表达式 , ✅ 验证 , ✅ 数据绑定 |
28- | ` <Button /> ` | ` { type: "button" } ` | ✅ 动作映射 , ✅ 加载状态 |
29- | ` <Select /> ` | ` { type: "select" } ` | ✅ 动态选项 , ✅ 远程搜索 |
30- | ` <Dialog /> ` | ` { type: "dialog" } ` | ✅ 条件显示 , ✅ 表单集成 |
31- | ` <Table /> ` | ` { type: "table" } ` | ✅ 基础表格渲染 |
32- | ` <Card /> ` | ` { type: "card" } ` | ✅ 动态内容 , ✅ 操作按钮 |
33- | ` <Form /> ` | ` { type: "form" } ` | ✅ 验证引擎 , ✅ 提交处理 |
34- | ` <Tabs /> ` | ` { type: "tabs" } ` | ✅ 动态标签 , ✅ 懒加载 |
35- | ` <Badge /> ` | ` { type: "badge" } ` | ✅ 状态映射 , ✅ 颜色规则 |
36- | ` <Alert /> ` | ` { type: "alert" } ` | ✅ 条件显示 , ✅ 自动关闭 |
27+ | ` <Input /> ` | ` { type: "input" } ` | ✅ Expressions , ✅ Validation , ✅ Data Binding |
28+ | ` <Button /> ` | ` { type: "button" } ` | ✅ Action Mapping , ✅ Loading States |
29+ | ` <Select /> ` | ` { type: "select" } ` | ✅ Dynamic Options , ✅ Remote Search |
30+ | ` <Dialog /> ` | ` { type: "dialog" } ` | ✅ Conditional Display , ✅ Form Integration |
31+ | ` <Table /> ` | ` { type: "table" } ` | ✅ Basic Table Rendering |
32+ | ` <Card /> ` | ` { type: "card" } ` | ✅ Dynamic Content , ✅ Action Buttons |
33+ | ` <Form /> ` | ` { type: "form" } ` | ✅ Validation Engine , ✅ Submit Handling |
34+ | ` <Tabs /> ` | ` { type: "tabs" } ` | ✅ Dynamic Tabs , ✅ Lazy Loading |
35+ | ` <Badge /> ` | ` { type: "badge" } ` | ✅ Status Mapping , ✅ Color Rules |
36+ | ` <Alert /> ` | ` { type: "alert" } ` | ✅ Conditional Display , ✅ Auto-dismiss |
3737
3838---
3939
40- ## ObjectUI独有组件
40+ ## ObjectUI Exclusive Components
4141
42- 这些组件没有直接对应的Shadcn组件,是ObjectUI的高级业务组件:
42+ These components have no direct Shadcn counterparts and are advanced business components unique to ObjectUI:
4343
44- | 组件 | 类型 | 用途 |
44+ | Component | Type | Purpose |
4545| ------| ------| ------|
46- | ** data-table** | 复杂组件 | 带排序/过滤/分页的高级表格 |
47- | ** timeline** | 复杂组件 | 时间线/甘特图 |
48- | ** filter-builder** | 复杂组件 | 可视化查询构建器 |
49- | ** chatbot** | 复杂组件 | 对话机器人界面 |
50- | ** tree-view** | 数据展示 | 树形结构 |
51- | ** statistic** | 数据展示 | 统计数值卡片 |
46+ | ** data-table** | Complex Component | Advanced table with sorting/filtering/pagination |
47+ | ** timeline** | Complex Component | Timeline/Gantt chart |
48+ | ** filter-builder** | Complex Component | Visual query builder |
49+ | ** chatbot** | Complex Component | Chatbot interface |
50+ | ** tree-view** | Data Display | Tree structure |
51+ | ** statistic** | Data Display | Statistical metric cards |
5252
5353---
5454
55- ## 使用场景对比
55+ ## Usage Comparison
5656
57- ### 场景1: 简单表单
57+ ### Scenario 1: Simple Form
5858
59- #### Shadcn方式 (React代码 )
59+ #### Shadcn Approach (React Code )
6060``` tsx
6161import { Input } from ' @/ui/input' ;
6262import { Button } from ' @/ui/button' ;
@@ -92,7 +92,7 @@ function LoginForm() {
9292}
9393```
9494
95- #### ObjectUI方式 (JSON Schema)
95+ #### ObjectUI Approach (JSON Schema)
9696``` json
9797{
9898 "type" : " form" ,
@@ -123,9 +123,9 @@ function LoginForm() {
123123}
124124```
125125
126- ### 场景2: 数据表格
126+ ### Scenario 2: Data Table
127127
128- #### Shadcn方式
128+ #### Shadcn Approach
129129``` tsx
130130import { Table } from ' @/ui/table' ;
131131
@@ -162,7 +162,7 @@ function UserTable() {
162162}
163163```
164164
165- #### ObjectUI方式
165+ #### ObjectUI Approach
166166``` json
167167{
168168 "type" : " data-table" ,
@@ -187,34 +187,34 @@ function UserTable() {
187187
188188---
189189
190- ## 选择指南
190+ ## Selection Guide
191191
192- ### 使用Shadcn UI(直接使用原生组件)
193- ✅ 需要高度定制化的交互逻辑
194- ✅ 组件行为复杂,难以用Schema表达
195- ✅ 性能极致优化(避免Schema解析开销)
196- ✅ 已有大量React组件代码
192+ ### Use Shadcn UI (Direct Native Components)
193+ ✅ Highly customized interaction logic required
194+ ✅ Complex component behavior difficult to express in Schema
195+ ✅ Performance-critical optimization (avoid Schema parsing overhead)
196+ ✅ Existing large React component codebase
197197
198- ### 使用ObjectUI渲染器(推荐)
199- ✅ 快速构建数据管理界面
200- ✅ 配置驱动,易于维护
201- ✅ 需要动态UI(从服务端获取配置)
202- ✅ 低代码/无代码平台
203- ✅ 需要AI生成UI
198+ ### Use ObjectUI Renderer (Recommended)
199+ ✅ Rapidly build data management interfaces
200+ ✅ Configuration-driven, easy to maintain
201+ ✅ Dynamic UI required (fetch configuration from server)
202+ ✅ Low-code/No-code platforms
203+ ✅ AI-generated UI
204204
205205---
206206
207- ## 混合使用
207+ ## Hybrid Approach
208208
209- ObjectUI支持在Schema中嵌入自定义React组件:
209+ ObjectUI supports embedding custom React components within Schema:
210210
211211``` json
212212{
213213 "type" : " page" ,
214214 "body" : [
215215 {
216216 "type" : " card" ,
217- "title" : " 用户统计 " ,
217+ "title" : " User Statistics " ,
218218 "body" : {
219219 "type" : " custom" ,
220220 "component" : " CustomChart" ,
@@ -232,7 +232,7 @@ ObjectUI支持在Schema中嵌入自定义React组件:
232232```
233233
234234``` tsx
235- // 注册自定义组件
235+ // Register custom component
236236import { registerRenderer } from ' @object-ui/react' ;
237237import CustomChart from ' ./CustomChart' ;
238238
@@ -244,29 +244,29 @@ registerRenderer('custom', ({ schema }) => {
244244
245245---
246246
247- ## 常见问题
247+ ## Frequently Asked Questions
248248
249- ### Q: ObjectUI渲染器性能如何?
250- A: 相比直接使用Shadcn有轻微开销( <10%),但通过虚拟化和缓存优化,在实际应用中差异不明显。
249+ ### Q: How is ObjectUI Renderer performance?
250+ A: Compared to using Shadcn directly, there is a slight overhead ( <10%), but with virtualization and caching optimizations, the difference is negligible in real-world applications.
251251
252- ### Q: 可以覆盖ObjectUI渲染器的样式吗?
253- A: 可以!通过 ` className ` 属性传入Tailwind类名即可覆盖。
252+ ### Q: Can I override ObjectUI Renderer styles?
253+ A: Yes! You can override styles by passing Tailwind class names via the ` className ` property.
254254
255- ### Q: 如何扩展ObjectUI不支持的组件?
256- A: 使用 ` registerRenderer ` 注册自定义渲染器,或使用 ` type: "custom" ` 嵌入React组件。
255+ ### Q: How do I extend components not supported by ObjectUI?
256+ A: Use ` registerRenderer ` to register custom renderers, or use ` type: "custom" ` to embed React components.
257257
258- ### Q: ObjectUI渲染器支持TypeScript吗?
259- A: 完全支持!所有Schema都有完整的TypeScript类型定义。
258+ ### Q: Does ObjectUI Renderer support TypeScript?
259+ A: Full support! All Schemas have complete TypeScript type definitions.
260260
261261---
262262
263- ## 更多资源
263+ ## Additional Resources
264264
265- - 📚 [ 组件API文档 ] ( ./components/ )
266- - 🎨 [ Storybook示例 ] ( https://storybook.objectui.org )
267- - 🔧 [ 自定义渲染器指南 ] ( ./guide/custom-renderers.md )
268- - 💡 [ 最佳实践 ] ( ./community/best-practices.md )
265+ - 📚 [ Component API Documentation ] ( ./components/ )
266+ - 🎨 [ Storybook Examples ] ( https://storybook.objectui.org )
267+ - 🔧 [ Custom Renderer Guide ] ( ./guide/custom-renderers.md )
268+ - 💡 [ Best Practices ] ( ./community/best-practices.md )
269269
270270---
271271
272- * 最后更新 : 2026-01-23*
272+ * Last Updated : 2026-01-23*
0 commit comments