Getting Started with Claude
In this tutorial, you'll learn how to use Claude to generate production-ready UI Lab components. By the end, you'll be able to describe what you want and get working, beautiful component code.
What You'll Build
We'll create a simple contact form component that:
- Has email and message fields
- Submits the form
- Shows validation errors
- Works on mobile and desktop
- Is fully accessible
And you'll have Claude generate the code for you.
Step 1: Set Up Your Project
First, make sure you have UI Lab components installed:
Then, import the theme provider in your main application file:
Step 2: Know What Components Are Available
Before talking to Claude, it helps to know what components UI Lab provides. Here are the main ones for building forms:
- Button – Call-to-action buttons with variants (primary, secondary, outline, ghost)
- Input – Text input fields with error states
- TextArea – Multi-line text input
- Label – Form field labels
- Form – Container for form fields
- FormField – Individual form field with validation
- Card – Container for grouping content
Step 3: Tell Claude About UI Lab
When prompting Claude, provide context about UI Lab. Here's what to include:
Option A: Simple Reference (Quick Start)
Give Claude this brief context:
Option B: Detailed Reference (Better Results)
Include more detail about design patterns:
Option C: Use MCP Server Integration (Best)
If you have the MCP server running, tell Claude:
Step 4: Write Your Prompt
Now ask Claude to generate your component. Here's a good prompt template:
Step 5: Review the Generated Code
Claude will generate something like this:
Perfect! This is production-ready code that:
- ✅ Is fully typed with TypeScript
- ✅ Includes proper accessibility
- ✅ Follows UI Lab patterns
- ✅ Handles errors gracefully
- ✅ Works on all screen sizes
- ✅ Supports dark mode automatically
Step 6: Customize if Needed
Claude may have generated more or less than you need. Common customizations:
Add a success state
Ask: "Add a success page that shows after submission with a 'Send Another' button"
Change the styling
Ask: "Make the form wider on desktop (max-w-2xl) and add a gradient background"
Add more fields
Ask: "Add a phone number field that's optional but validated if provided"
Integrate with an API
Ask: "Replace the setTimeout with a real API call to POST /api/contact"
Common Prompting Patterns
Pattern 1: Feature Request
Pattern 2: Styling Request
Pattern 3: Composition Request
Pattern 4: Accessibility Fix
Tips for Better Results
-
Be Specific – Instead of "make it look better," say "use a card layout with rounded corners and a subtle shadow"
-
Reference Components – Mention specific UI Lab components you want used: "use a Grid with 2 columns"
-
Show Examples – If you have existing components, show them to Claude: "make it look like this [example code]"
-
Use TypeScript – Ask for typed code: "Generate with full TypeScript types"
-
Request Testing Code – Ask Claude to include test examples: "Add usage examples showing how to use this component"
-
Mention Constraints – Tell Claude about limitations: "Keep the bundle size small," "use only CSS, no CSS-in-JS"
What's Next
Now that you know how to generate components with Claude:
- Learn More Patterns → Examples & Patterns
- Understand Design Guidelines → Design Guidelines Reference
- Set Up MCP for Real-Time Updates → MCP Server Setup
- Explore the Registry → Component Registry Reference
Troubleshooting
Claude generates invalid prop names
Solution: Ensure Claude knows the exact prop names. Give it the component documentation or MCP access.
Generated code doesn't compile
Solution: Ask Claude to check TypeScript types. Share the error message: "I got this error: [error]. Please fix it."
Styling doesn't match your design
Solution: Provide more detail about the design. Include color tokens and spacing values from your theme.
Accessibility issues
Solution: Ask Claude to add specific accessibility features: "Add aria-labels for icon buttons"
You're now ready to generate beautiful UI Lab components with Claude. Happy coding!