Shadcn UI Designer
Core Design Prompt
When designing any UI, apply this philosophy:
"Design a modern, clean UI following Shadcn principles: apply minimalism with ample white space and simple sans-serif typography; use strategic, subtle shadows for depth and hierarchy; ensure accessibility with high-contrast neutrals and scalable elements; provide beautiful defaults for buttons, cards, and forms that compose modularly; incorporate fluid, non-intrusive animations; maintain a professional palette of soft grays, whites, and minimal accents like purple; output as responsive, customizable React code with Tailwind CSS."
Design Rules
1. Typography Rule
- Limit to 2-3 font weights and sizes per screen
- Use Inter or system fonts for consistency
<h1 className="text-2xl font-semibold">Title</h1>
<p className="text-sm text-muted-foreground">Description</p>
2. Spacing Rule
- 4px-based scale: 4px, 8px, 16px, 24px, 32px
- Tailwind utilities:
p-1, p-2, p-4, p-6, p-8
<div className="p-6 space-y-4">
<div className="mb-8">...</div>
</div>
3. Color Rule
- Base on OKLCH for perceptual uniformity
- Use 50-950 scale grays (background, foreground, muted)
- Subtle accents at 10% opacity to avoid visual noise
<Card className="bg-card text-card-foreground border-border">
<Button className="bg-primary text-primary-foreground">Action</Button>
<div className="bg-primary/10">Subtle accent</div>
</Card>
4. Shadow Rule
- 3 levels only:
shadow-sm: Subtle lift (0 1px 2px) - for cards
shadow-md: Medium depth (0 4px 6px) - for dropdowns
shadow-lg: High elevation (0 10px 15px) - for modals
<Card className="shadow-sm hover:shadow-md transition-shadow">
5. Animation Rule
- 200-300ms durations
- ease-in-out curves for transitions
- Subtle feedback only (hovers, state changes) - no decorative flourishes
<Button className="transition-colors duration-200 hover:bg-primary/90">
<Card className="transition-transform duration-200 hover:scale-105">
6. Accessibility Rule
- ARIA labels on all interactive elements
- WCAG 2.1 AA contrast ratios (4.5:1 minimum)
- Keyboard-focus styles matching hover states
- Semantic HTML structure
<button
aria-label="Submit form"
className="focus:ring-2 focus:ring-primary focus:outline-none"
>
Submit
</button>
Workflow
1. Interview User (if details not provided)
- Scope: Full page, section, or specific component?
- Type: Dashboard, form, card, modal, table?
- Target file: Where should this be implemented?
- Requirements: Features, interactions, data to display?
2. Design & Implement
- Match existing design - align with current UI patterns in the app
- Build UI first - complete visual interface before adding logic
- Modular components - break large pages into focused, reusable pieces
- Apply all 6 rules above strictly
- Verify accessibility - keyboard navigation, contrast, ARIA labels
- Test responsiveness - mobile, tablet, desktop
3. Component Structure Pattern
import { Button } from "@/components/ui/button"
import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card"
export function MyComponent() {
return (
<div className="container mx-auto p-6 space-y-6">
<header>
<h1 className="text-2xl font-semibold">Page Title</h1>
</header>
<main className="grid gap-4">
<Card className="shadow-sm">
<CardHeader>
<CardTitle>Section</CardTitle>
</CardHeader>
<CardContent>
{/* Content */}
</CardContent>
</Card>
</main>
</div>
)
}
4. Quality Checklist
Before completing, verify:
Common Patterns
Dashboard Page
<div className="container mx-auto p-6 space-y-6">
<header className="space-y-2">
<h1 className="text-2xl font-semibold">Dashboard</h1>
<p className="text-sm text-muted-foreground">Overview of metrics</p>
</header>
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-4">
{stats.map(stat => (
<Card key={stat.id} className="shadow-sm">
<CardHeader className="pb-2">
<CardTitle className="text-sm font-medium text-muted-foreground">
{stat.title}
</CardTitle>
</CardHeader>
<CardContent>
<div className="text-2xl font-semibold">{stat.value}</div>
</CardContent>
</Card>
))}
</div>
</div>
Form Pattern
<form className="space-y-6">
<div className="space-y-4">
<div className="space-y-2">
<Label htmlFor="name">Full Name</Label>
<Input id="name" placeholder="John Doe" />
</div>
<div className="space-y-2">
<Label htmlFor="email">Email</Label>
<Input id="email" type="email" placeholder="john@example.com" />
</div>
</div>
<Button type="submit" className="w-full transition-colors duration-200">
Submit
</Button>
</form>
Data Table Pattern
<Card className="shadow-sm">
<CardHeader>
<CardTitle className="text-xl font-semibold">Recent Orders</CardTitle>
</CardHeader>
<CardContent>
<Table>
<TableHeader>
<TableRow>
<TableHead>Order ID</TableHead>
<TableHead>Customer</TableHead>
<TableHead>Status</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{orders.map(order => (
<TableRow key={order.id} className="hover:bg-muted/50 transition-colors">
<TableCell className="font-medium">{order.id}</TableCell>
<TableCell>{order.customer}</TableCell>
<TableCell>
<Badge variant="default">{order.status}</Badge>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</CardContent>
</Card>
Best Practices
- Match existing design - new designs align with current UI screens and components
- UI-first approach - complete visual interface before adding business logic
- Modular code - small, focused, reusable components (avoid monolithic pages)
- Token efficiency - concise, well-structured code
- Consistency - follow existing color, spacing, and typography patterns
- Composability - build with shadcn's philosophy of small components that work together
Common Shadcn Components
- Layout: Card, Tabs, Sheet, Dialog, Popover
- Forms: Input, Textarea, Select, Checkbox, Radio, Switch, Label
- Buttons: Button, Toggle, ToggleGroup
- Display: Badge, Avatar, Separator, Skeleton, Table
- Feedback: Alert, Toast, Progress
- Navigation: NavigationMenu, Dropdown, Command
References
1---2name: component-interface-design3description: Design interfaces using component libraries and design systems. Creates cohesive UIs with pre-built accessible component primitives.4license: Proprietary. LICENSE.txt has complete terms5---6
7# Shadcn UI Designer
8
9## Core Design Prompt
10
11When designing any UI, apply this philosophy:
12
13> "Design a modern, clean UI following Shadcn principles: apply minimalism with ample white space and simple sans-serif typography; use strategic, subtle shadows for depth and hierarchy; ensure accessibility with high-contrast neutrals and scalable elements; provide beautiful defaults for buttons, cards, and forms that compose modularly; incorporate fluid, non-intrusive animations; maintain a professional palette of soft grays, whites, and minimal accents like purple; output as responsive, customizable React code with Tailwind CSS."
14
15## Design Rules
16
17### 1. Typography Rule
18- Limit to **2-3 font weights and sizes** per screen
19- Use **Inter** or system fonts for consistency
20```tsx
21<h1 className="text-2xl font-semibold">Title</h1>
22<p className="text-sm text-muted-foreground">Description</p>
23```
24
25### 2. Spacing Rule
26- **4px-based scale**: 4px, 8px, 16px, 24px, 32px
27- Tailwind utilities: `p-1`, `p-2`, `p-4`, `p-6`, `p-8`
28```tsx
29<div className="p-6 space-y-4">
30 <div className="mb-8">...</div>
31</div>
32```
33
34### 3. Color Rule
35- Base on **OKLCH** for perceptual uniformity
36- Use **50-950 scale grays** (background, foreground, muted)
37- **Subtle accents** at 10% opacity to avoid visual noise
38```tsx
39<Card className="bg-card text-card-foreground border-border">
40 <Button className="bg-primary text-primary-foreground">Action</Button>
41 <div className="bg-primary/10">Subtle accent</div>
42</Card>
43```
44
45### 4. Shadow Rule
46- **3 levels only**:
47 - `shadow-sm`: Subtle lift (0 1px 2px) - for cards
48 - `shadow-md`: Medium depth (0 4px 6px) - for dropdowns
49 - `shadow-lg`: High elevation (0 10px 15px) - for modals
50```tsx
51<Card className="shadow-sm hover:shadow-md transition-shadow">
52```
53
54### 5. Animation Rule
55- **200-300ms durations**
56- **ease-in-out** curves for transitions
57- **Subtle feedback** only (hovers, state changes) - no decorative flourishes
58```tsx
59<Button className="transition-colors duration-200 hover:bg-primary/90">
60<Card className="transition-transform duration-200 hover:scale-105">
61```
62
63### 6. Accessibility Rule
64- **ARIA labels** on all interactive elements
65- **WCAG 2.1 AA** contrast ratios (4.5:1 minimum)
66- **Keyboard-focus styles** matching hover states
67- **Semantic HTML** structure
68```tsx
69<button
70 aria-label="Submit form"
71 className="focus:ring-2 focus:ring-primary focus:outline-none"
72>
73 Submit
74</button>
75```
76
77## Workflow
78
79### 1. Interview User (if details not provided)
80- **Scope**: Full page, section, or specific component?
81- **Type**: Dashboard, form, card, modal, table?
82- **Target file**: Where should this be implemented?
83- **Requirements**: Features, interactions, data to display?
84
85### 2. Design & Implement
861. **Match existing design** - align with current UI patterns in the app
872. **Build UI first** - complete visual interface before adding logic
883. **Modular components** - break large pages into focused, reusable pieces
894. **Apply all 6 rules** above strictly
905. **Verify accessibility** - keyboard navigation, contrast, ARIA labels
916. **Test responsiveness** - mobile, tablet, desktop
92
93### 3. Component Structure Pattern
94```tsx
95import { Button } from "@/components/ui/button"
96import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card"
97
98export function MyComponent() {
99 return (
100 <div className="container mx-auto p-6 space-y-6">
101 <header>
102 <h1 className="text-2xl font-semibold">Page Title</h1>
103 </header>
104
105 <main className="grid gap-4">
106 <Card className="shadow-sm">
107 <CardHeader>
108 <CardTitle>Section</CardTitle>
109 </CardHeader>
110 <CardContent>
111 {/* Content */}
112 </CardContent>
113 </Card>
114 </main>
115 </div>
116 )
117}
118```
119
120### 4. Quality Checklist
121Before completing, verify:
122- [ ] Uses shadcn/ui components where applicable
123- [ ] 2-3 font weights/sizes max per screen
124- [ ] 4px-based spacing throughout
125- [ ] Theme color variables (no hardcoded colors)
126- [ ] 3 shadow levels max, strategically applied
127- [ ] Animations 200-300ms with ease-in-out
128- [ ] ARIA labels on interactive elements
129- [ ] WCAG AA contrast ratios (4.5:1 min)
130- [ ] Keyboard focus styles implemented
131- [ ] Mobile-first responsive design
132- [ ] Modular, reusable code structure
133
134## Common Patterns
135
136### Dashboard Page
137```tsx
138<div className="container mx-auto p-6 space-y-6">
139 <header className="space-y-2">
140 <h1 className="text-2xl font-semibold">Dashboard</h1>
141 <p className="text-sm text-muted-foreground">Overview of metrics</p>
142 </header>
143
144 <div className="grid gap-4 md:grid-cols-2 lg:grid-cols-4">
145 {stats.map(stat => (
146 <Card key={stat.id} className="shadow-sm">
147 <CardHeader className="pb-2">
148 <CardTitle className="text-sm font-medium text-muted-foreground">
149 {stat.title}
150 </CardTitle>
151 </CardHeader>
152 <CardContent>
153 <div className="text-2xl font-semibold">{stat.value}</div>
154 </CardContent>
155 </Card>
156 ))}
157 </div>
158</div>
159```
160
161### Form Pattern
162```tsx
163<form className="space-y-6">
164 <div className="space-y-4">
165 <div className="space-y-2">
166 <Label htmlFor="name">Full Name</Label>
167 <Input id="name" placeholder="John Doe" />
168 </div>
169 <div className="space-y-2">
170 <Label htmlFor="email">Email</Label>
171 <Input id="email" type="email" placeholder="john@example.com" />
172 </div>
173 </div>
174 <Button type="submit" className="w-full transition-colors duration-200">
175 Submit
176 </Button>
177</form>
178```
179
180### Data Table Pattern
181```tsx
182<Card className="shadow-sm">
183 <CardHeader>
184 <CardTitle className="text-xl font-semibold">Recent Orders</CardTitle>
185 </CardHeader>
186 <CardContent>
187 <Table>
188 <TableHeader>
189 <TableRow>
190 <TableHead>Order ID</TableHead>
191 <TableHead>Customer</TableHead>
192 <TableHead>Status</TableHead>
193 </TableRow>
194 </TableHeader>
195 <TableBody>
196 {orders.map(order => (
197 <TableRow key={order.id} className="hover:bg-muted/50 transition-colors">
198 <TableCell className="font-medium">{order.id}</TableCell>
199 <TableCell>{order.customer}</TableCell>
200 <TableCell>
201 <Badge variant="default">{order.status}</Badge>
202 </TableCell>
203 </TableRow>
204 ))}
205 </TableBody>
206 </Table>
207 </CardContent>
208</Card>
209```
210
211## Best Practices
212
213- **Match existing design** - new designs align with current UI screens and components
214- **UI-first approach** - complete visual interface before adding business logic
215- **Modular code** - small, focused, reusable components (avoid monolithic pages)
216- **Token efficiency** - concise, well-structured code
217- **Consistency** - follow existing color, spacing, and typography patterns
218- **Composability** - build with shadcn's philosophy of small components that work together
219
220## Common Shadcn Components
221
222- **Layout**: Card, Tabs, Sheet, Dialog, Popover
223- **Forms**: Input, Textarea, Select, Checkbox, Radio, Switch, Label
224- **Buttons**: Button, Toggle, ToggleGroup
225- **Display**: Badge, Avatar, Separator, Skeleton, Table
226- **Feedback**: Alert, Toast, Progress
227- **Navigation**: NavigationMenu, Dropdown, Command
228
229## References
230
231- [Shadcn UI](https://ui.shadcn.com)
232- [Tailwind CSS v4](https://tailwindcss.com)
233- [WCAG 2.1](https://www.w3.org/WAI/WCAG21/quickref/)