Understanding the Component Registry
The Component Registry is the foundation of UI Lab's AI integration. It's a structured, machine-readable catalog that answers one fundamental question: What can AI generate with UI Lab, and how?
This document explains the why and how of the registry—what it contains, how it's organized, and why it matters for AI systems.
The Problem It Solves
When Claude (or any AI) generates React code with a component library, it faces dozens of decisions:
- Discovery: What components are available?
- Selection: Which component should I use for this task?
- Variants: What variants/props does this component have?
- Composition: How do components work together?
- Accessibility: What ARIA attributes are needed?
- Theming: Which design tokens should I reference?
- Responsive: How should this respond to different screen sizes?
Traditional component libraries answer these implicitly—you read the docs, memorize patterns, try combinations. AI can't do that reliably. The registry makes these answers explicit and machine-readable.
What's in the Registry
Each component has comprehensive metadata:
Core Sections Explained
1. Identity
Why this matters:
id: Allows AI to uniquely reference components programmaticallycategory: Helps AI discover related components (all "action" components)tags: Enables semantic searches ("find a CTA component")
2. Variants with Semantics
Why this matters:
- Each variant has semantic meaning, not just visual difference
- AI knows not just "this variant exists," but when to use it
- Prevents AI from randomly choosing variants
3. Props with Context
Why this matters:
- AI knows the exact type and allowed values
- No guessing about prop names or values
- Enables type checking in generated code
4. Accessibility Guarantees
Why this matters:
- AI knows what accessibility features are available
- Knows what ARIA attributes to use
- Can validate accessibility before generating code
5. Composition Rules
Why this matters:
- AI knows what components can be children/parents
- Understands common patterns (button groups, etc.)
- Can suggest related components
6. Design System Integration
Why this matters:
- AI references semantic tokens instead of hardcoding colors
- Knows the component supports dark mode
- Has concrete examples to follow
How AI Uses the Registry
1. Discovery Phase
2. Selection Phase
3. Composition Phase
4. Accessibility Phase
5. Code Generation
Why This Approach Works
For AI Systems
- Explicit over Implicit – No guessing; everything is documented
- Semantic over Visual – Variants have meaning, not just appearance
- Composable – Clear patterns for combining components
- Accessible by Default – Accessibility is built in and documented
- Design System Aware – Uses tokens, responds to themes
For Developers
- Better AI Code – Claude understands why components are used
- Consistency – AI generates code that matches design patterns
- Maintenance – Update registry once, AI learns automatically
- Validation – Registry can validate AI-generated code
- Documentation – Registry serves as source of truth
Registry Structure in the Codebase
The registry is typically structured as:
Each component metadata file contains the structure described above.
Accessing the Registry
Programmatically (JavaScript/TypeScript)
Via LLMs.txt
Generates a text file with all component documentation in LLMs.txt format.
Via MCP Server
Extending the Registry
To add a new component to the registry:
- Create component metadata in
packages/registry/src/components/[name].ts - Include all sections: identity, variants, props, accessibility, composition, design
- Add examples showing common usage patterns
- Document composition rules with other components
- Run registry generation to update
generated-data.ts - Update main registry index
Example:
Design Philosophy
The registry embodies these principles:
- Semantics Over Configuration – Variants mean something, props have purpose
- Explicit Over Implicit – Everything is documented, nothing is assumed
- Composable Over Complex – Simple components that work together
- Accessible by Default – Accessibility is built-in, not optional
- AI-First – Designed specifically for machine consumption
Next Steps
- See Full Registry → Component Registry Reference
- Learn Design Guidelines → Design Guidelines Reference
- Set Up MCP Server → MCP Server Setup
- View Examples → Examples & Patterns
The registry is UI Lab's contract with AI: complete information for confident code generation.