6.6 KiB
JSON UI Components Registry
This document describes the JSON UI component system and lists all components that can be rendered from JSON schemas.
Overview
The JSON UI system allows you to define user interfaces using JSON schemas instead of writing React code. This is useful for:
- Dynamic UI generation
- No-code/low-code interfaces
- Configuration-driven UIs
- Rapid prototyping
Quick Start
List All JSON-Compatible Components
# List all components with details
npm run components:list
# List only supported components
npm run components:list -- --status=supported
# List only planned components
npm run components:list -- --status=planned
# Output as JSON
npm run components:list -- --format=json
Using JSON UI Components
Components are defined in the ComponentType union in src/types/json-ui.ts and registered in src/lib/json-ui/component-registry.tsx.
Example JSON schema:
{
"id": "example-page",
"type": "Card",
"props": {
"className": "p-6"
},
"children": [
{
"id": "heading",
"type": "Heading",
"props": {
"level": 2,
"children": "Welcome"
}
},
{
"id": "description",
"type": "Text",
"props": {
"children": "This is a dynamically rendered component"
}
},
{
"id": "cta",
"type": "Button",
"props": {
"variant": "default",
"children": "Get Started"
}
}
]
}
Component Categories
Layout Components (12)
Container elements for organizing content:
div,section,article,header,footer,main- HTML semantic elementsCard- Container with optional header, content, and footerGrid- Responsive grid layoutStack- Vertical or horizontal stack layoutFlex- Flexible box layoutContainer- Centered container with max-widthDialog- Modal dialog overlay
Input Components (11)
Form inputs and interactive controls:
Button- Interactive buttonInput- Text input fieldTextArea- Multi-line text inputSelect- Dropdown selectCheckbox- Checkbox toggleRadio- Radio buttonSwitch- Toggle switchSlider- Numeric range sliderNumberInput- Numeric input with increment/decrementDatePicker- Date selection (planned)FileUpload- File upload control (planned)
Display Components (16)
Presentation and visual elements:
Heading- Heading text (h1-h6)Text- Text content with typographyLabel- Form labelBadge- Status or count indicatorTag- Removable tag/chipCode- Inline or block codeImage- Image with loading statesAvatar- User avatar imageIcon- Icon from library (planned)Progress- Progress barSpinner- Loading spinnerSkeleton- Loading placeholderSeparator- Visual dividerCircularProgress- Circular indicator (planned)ProgressBar- Linear progress (planned)Divider- Section divider (planned)
Navigation Components (3)
Navigation and routing:
Link- Hyperlink elementBreadcrumb- Navigation trail (planned)Tabs- Tabbed interface
Feedback Components (7)
Alerts, notifications, and status:
Alert- Alert notification messageInfoBox- Information box with iconEmptyState- Empty state placeholderStatusBadge- Status indicatorStatusIcon- Status icon (planned)ErrorBadge- Error state (planned)Notification- Toast notification (planned)
Data Components (8)
Data display and visualization:
List- Generic list rendererTable- Data tableKeyValue- Key-value pair displayStatCard- Statistic cardDataList- Styled data list (planned)DataTable- Advanced table with sorting/filtering (planned)Timeline- Timeline visualization (planned)MetricCard- Metric display (planned)
Custom Components (3)
Domain-specific components:
DataCard- Custom data display cardSearchInput- Search input with iconActionBar- Action button toolbar
Current Status
- Total Components: 60
- Supported: 46 (77%)
- Planned: 14 (23%)
Files
json-components-registry.json- Complete registry with metadatasrc/types/json-ui.ts- TypeScript types and ComponentType unionsrc/lib/json-ui/component-registry.tsx- Component registry mappingsrc/lib/component-definitions.ts- Component definitions with defaultsscripts/list-json-components.cjs- CLI tool to list components
Adding New Components
To add a new component to the JSON UI system:
- Add the component type to
ComponentTypeunion insrc/types/json-ui.ts - Import and register it in
src/lib/json-ui/component-registry.tsx - Add component definition in
src/lib/component-definitions.ts - Update
json-components-registry.jsonwith metadata - Test the component in a JSON schema
JSON Compatibility Checklist
Before migrating a component, confirm all required conditions are met:
- Hooks/state are registry-safe: hooks and internal state are acceptable when the component registry can control or expose them through JSON bindings.
- Bindings are defined: any required actions, event handlers, or state bindings are already supported by the JSON UI binding system.
- Refactoring covered by PR: JSON compatibility gaps should be resolved via refactoring as part of the same pull request.
Step-by-Step Migration Path
Use this repeatable migration flow for planned components:
- Update the type union in
src/types/json-ui.tsto include the new component type name. - Register the component in
src/lib/json-ui/component-registry.tsxso JSON schemas can resolve it at runtime. - Define component metadata in
src/lib/component-definitions.ts(defaults, prop schema, and any JSON-driven constraints). - Validate JSON schema usage by rendering a sample schema that uses the new type.
- Update registry metadata in
json-components-registry.jsonso the CLI/listing reflects the new status.
Migration Strategy
Components marked as "planned" are:
- Available in the codebase as React components
- Not yet integrated into the JSON UI system
- Can be migrated following the steps above
Priority for migration:
- High-usage components
- Components with simple props
- Components with good atomic design
- Components without complex state management
Related Documentation
- PRD.md - Product requirements document
- REDUX_DOCUMENTATION.md - Redux integration
- src/types/json-ui.ts - Type definitions
- src/lib/component-definitions.ts - Component metadata