Frontend UI Engineering

Frontend UI Engineering

Guides an AI agent to build production-quality, accessible, responsive user interfaces with sound component structure, state handling and design-system discipline instead of generic AI looks.

Skill files2 files

references/shared/

SKILL.md347 lines
1
---
2
name: frontend-ui-engineering
3
description: Builds production-quality, accessible, responsive user-facing UIs. Use when building or modifying interfaces and pages, creating components, implementing layouts, meeting WCAG accessibility requirements, managing state, or when the output needs to look and feel production-quality rather than AI-generated.
4
---
5
6
# Frontend UI Engineering
7
8
## Overview
9
10
Build production-quality user interfaces that are accessible, performant, and visually polished. The goal is UI that looks like it was built by a design-aware engineer at a top company — not like it was generated by an AI. This means real design system adherence, proper accessibility, thoughtful interaction patterns, and no generic "AI aesthetic."
11
12
## When to Use
13
14
- Building new UI components or pages
15
- Modifying existing user-facing interfaces
16
- Implementing responsive layouts
17
- Adding interactivity or state management
18
- Fixing visual or UX issues
19
20
## Verify With What the Project Has
21
22
Run the project's own test, type-check, or lint commands. Don't install a framework, test runner, or type checker just to check your work; if the project has none, review the code against the [Verification](#verification) list and say what you could not run.
23
24
## Component Architecture
25
26
### File Structure
27
28
Colocate everything related to a component:
29
30
```
31
src/components/
32
TaskList/
33
TaskList.tsx # Component implementation
34
TaskList.test.tsx # Tests
35
TaskList.stories.tsx # Storybook stories (if using)
36
use-task-list.ts # Custom hook (if complex state)
37
types.ts # Component-specific types (if needed)
38
```
39
40
### Component Patterns
41
42
**Prefer composition over configuration:**
43
44
```tsx
45
// Good: Composable
46
<Card>
47
<CardHeader>
48
<CardTitle>Tasks</CardTitle>
49
</CardHeader>
50
<CardBody>
51
<TaskList tasks={tasks} />
52
</CardBody>
53
</Card>
54
55
// Avoid: Over-configured
56
<Card
57
title="Tasks"
58
headerVariant="large"
59
bodyPadding="md"
60
content={<TaskList tasks={tasks} />}
61
/>
62
```
63
64
**Keep components focused:**
65
66
```tsx
67
// Good: Does one thing
68
export function TaskItem({ task, onToggle, onDelete }: TaskItemProps) {
69
return (
70
<li className="flex items-center gap-3 p-3">
71
<Checkbox checked={task.done} onChange={() => onToggle(task.id)} />
72
<span className={task.done ? 'line-through text-muted' : ''}>{task.title}</span>
73
<Button variant="ghost" size="sm" onClick={() => onDelete(task.id)}>
74
<TrashIcon />
75
</Button>
76
</li>
77
);
78
}
79
```
80
81
**Separate data fetching from presentation:**
82
83
```tsx
84
// Container: handles data
85
export function TaskListContainer() {
86
const { tasks, isLoading, error, refetch, toggleTask, deleteTask } = useTasks();
87
88
if (isLoading) return <TaskListSkeleton />;
89
if (error) return <ErrorState message="Failed to load tasks" retry={refetch} />;
90
if (tasks.length === 0) return <EmptyState message="No tasks yet" />;
91
92
return <TaskList tasks={tasks} onToggle={toggleTask} onDelete={deleteTask} />;
93
}
94
95
// Presentation: handles rendering
96
export function TaskList({ tasks, onToggle, onDelete }: { tasks: Task[] } & Pick<TaskItemProps, 'onToggle' | 'onDelete'>) {
97
return (
98
<ul role="list" className="divide-y">
99
{tasks.map(task => <TaskItem key={task.id} task={task} onToggle={onToggle} onDelete={onDelete} />)}
100
</ul>
101
);
102
}
103
```
104
105
## State Management
106
107
**Choose the simplest approach that works:**
108
109
```
110
Local state (useState) → Component-specific UI state
111
Lifted state → Shared between 2-3 sibling components
112
Context → Theme, auth, locale (read-heavy, write-rare)
113
URL state (searchParams) → Filters, pagination, shareable UI state
114
Server state (React Query, SWR) → Remote data with caching
115
Global store (Zustand, Redux) → Complex client state shared app-wide
116
```
117
118
**Avoid prop drilling deeper than 3 levels.** If you're passing props through components that don't use them, introduce context or restructure the component tree.
119
120
## Design System Adherence
121
122
### Reference-led UI quality
123
124
When the product needs a distinct visual direction, collect evidence before choosing a layout:
125
126
1. Search a trusted reference catalogue or use references supplied by the product team.
127
2. Study two or three relevant screens. Record decisions about hierarchy, density, navigation, controls, responsive behavior, and interaction states.
128
3. Turn those decisions into a short design contract before implementation. Name the screen's job, primary action, required states, responsive rules, and patterns to reject.
129
4. Rebuild the useful structure in the product's own components, tokens, content, and visual language. Never copy another product's branding, proprietary text, imagery, or exact layout.
130
131
Use references as evidence, not as templates. If references are unavailable, document the assumptions and verify the result against the product's existing design system.
132
133
### Avoid the AI Aesthetic
134
135
AI-generated UI has recognizable patterns. Avoid all of them:
136
137
| AI Default | Why It Is a Problem | Production Quality |
138
|---|---|---|
139
| Purple/indigo everything | Models default to visually "safe" palettes, making every app look identical | Use the project's actual color palette |
140
| Excessive gradients | Gradients add visual noise and clash with most design systems | Flat or subtle gradients matching the design system |
141
| Rounded everything (rounded-2xl) | Maximum rounding signals "friendly" but ignores the hierarchy of corner radii in real designs | Consistent border-radius from the design system |
142
| Generic hero sections | Template-driven layout with no connection to the actual content or user need | Content-first layouts |
143
| Lorem ipsum-style copy | Placeholder text hides layout problems that real content reveals (length, wrapping, overflow) | Realistic placeholder content |
144
| Oversized padding everywhere | Equal generous padding destroys visual hierarchy and wastes screen space | Consistent spacing scale |
145
| Stock card grids | Uniform grids are a layout shortcut that ignores information priority and scanning patterns | Purpose-driven layouts |
146
| Shadow-heavy design | Layered shadows add depth that competes with content and slows rendering on low-end devices | Subtle or no shadows unless the design system specifies |
147
148
### Spacing and Layout
149
150
Use a consistent spacing scale. Don't invent values:
151
152
```css
153
/* Use the scale: 0.25rem increments (or whatever the project uses) */
154
/* Good */ padding: 1rem; /* 16px */
155
/* Good */ gap: 0.75rem; /* 12px */
156
/* Bad */ padding: 13px; /* Not on any scale */
157
/* Bad */ margin-top: 2.3rem; /* Not on any scale */
158
```
159
160
### Typography
161
162
Respect the type hierarchy:
163
164
```
165
h1 → Page title (one per page)
166
h2 → Section title
167
h3 → Subsection title
168
body → Default text
169
small → Secondary/helper text
170
```
171
172
Don't skip heading levels. Don't use heading styles for non-heading content.
173
174
### Color
175
176
- Use semantic color tokens: `text-primary`, `bg-surface`, `border-default` — not raw hex values
177
- Ensure sufficient contrast (4.5:1 for normal text, 3:1 for large text)
178
- Don't rely solely on color to convey information (use icons, text, or patterns too)
179
180
## Accessibility (WCAG 2.1 AA)
181
182
Every component must meet these standards:
183
184
For menus, dialogs, tabs, listboxes and comboboxes, follow the [WAI-ARIA APG pattern](https://www.w3.org/WAI/ARIA/apg/patterns/) exactly.
185
186
### Keyboard Navigation
187
188
```tsx
189
// Every interactive element must be keyboard accessible
190
<button onClick={handleClick}>Click me</button> // ✓ Focusable by default
191
<div onClick={handleClick}>Click me</div> // ✗ Not focusable
192
<div role="button" tabIndex={0} onClick={handleClick} // ✓ But prefer <button>
193
onKeyDown={e => {
194
if (e.key === 'Enter') handleClick();
195
if (e.key === ' ') e.preventDefault();
196
}}
197
onKeyUp={e => {
198
if (e.key === ' ') handleClick();
199
}}>
200
Click me
201
</div>
202
```
203
204
### ARIA Labels
205
206
```tsx
207
// Label interactive elements that lack visible text
208
<button aria-label="Close dialog"><XIcon /></button>
209
210
// Label form inputs
211
<label htmlFor="email">Email</label>
212
<input id="email" type="email" />
213
214
// Or use aria-label when no visible label exists
215
<input aria-label="Search tasks" type="search" />
216
```
217
218
### Focus Management
219
220
```tsx
221
// Move focus when content changes
222
function Dialog({ isOpen, onClose }: DialogProps) {
223
const closeRef = useRef<HTMLButtonElement>(null);
224
225
useEffect(() => {
226
if (isOpen) closeRef.current?.focus();
227
}, [isOpen]);
228
229
// Trap focus inside dialog when open
230
return (
231
<dialog open={isOpen}>
232
<button ref={closeRef} onClick={onClose}>Close</button>
233
{/* dialog content */}
234
</dialog>
235
);
236
}
237
```
238
239
### Meaningful Empty and Error States
240
241
```tsx
242
// Don't show blank screens
243
function TaskList({ tasks, onCreateTask }: { tasks: Task[]; onCreateTask: () => void }) {
244
if (tasks.length === 0) {
245
return (
246
<div role="status" className="text-center py-12">
247
<TasksEmptyIcon className="mx-auto h-12 w-12 text-muted" />
248
<h3 className="mt-2 text-sm font-medium">No tasks</h3>
249
<p className="mt-1 text-sm text-muted">Get started by creating a new task.</p>
250
<Button className="mt-4" onClick={onCreateTask}>Create Task</Button>
251
</div>
252
);
253
}
254
255
return <ul role="list">...</ul>;
256
}
257
```
258
259
## Responsive Design
260
261
Design for mobile first, then expand:
262
263
```tsx
264
// Tailwind: mobile-first responsive
265
<div className="
266
grid grid-cols-1 /* Mobile: single column */
267
sm:grid-cols-2 /* Small: 2 columns */
268
lg:grid-cols-3 /* Large: 3 columns */
269
gap-4
270
">
271
```
272
273
Test at these breakpoints: 320px, 768px, 1024px, 1440px.
274
275
## Loading and Transitions
276
277
```tsx
278
// Skeleton loading (not spinners for content)
279
function TaskListSkeleton() {
280
return (
281
<div className="space-y-3" role="status" aria-busy="true" aria-label="Loading tasks">
282
{Array.from({ length: 3 }).map((_, i) => (
283
<div key={i} className="h-12 bg-muted animate-pulse rounded" />
284
))}
285
</div>
286
);
287
}
288
289
// Optimistic updates for perceived speed
290
function useToggleTask() {
291
const queryClient = useQueryClient();
292
293
return useMutation({
294
mutationFn: toggleTask,
295
onMutate: async (taskId) => {
296
await queryClient.cancelQueries({ queryKey: ['tasks'] });
297
const previous = queryClient.getQueryData(['tasks']);
298
299
queryClient.setQueryData(['tasks'], (old: Task[]) =>
300
old.map(t => t.id === taskId ? { ...t, done: !t.done } : t)
301
);
302
303
return { previous };
304
},
305
onError: (_err, _taskId, context) => {
306
queryClient.setQueryData(['tasks'], context?.previous);
307
},
308
});
309
}
310
```
311
312
## See Also
313
314
For detailed accessibility requirements and testing tools, see `references/shared/accessibility-checklist.md`.
315
316
## Common Rationalizations
317
318
| Rationalization | Reality |
319
|---|---|
320
| "Accessibility is a nice-to-have" | It's a legal requirement in many jurisdictions and an engineering quality standard. |
321
| "We'll make it responsive later" | Retrofitting responsive design is 3x harder than building it from the start. |
322
| "The design isn't final, so I'll skip styling" | Use the design system defaults. Unstyled UI creates a broken first impression for reviewers. |
323
| "This is just a prototype" | Prototypes become production code. Build the foundation right. |
324
| "The AI aesthetic is fine for now" | It signals low quality. Use the project's actual design system from the start. |
325
326
## Red Flags
327
328
- Components with more than 200 lines (split them)
329
- Inline styles or arbitrary pixel values
330
- Missing error states, loading states, or empty states
331
- No keyboard navigation testing
332
- Color as the sole indicator of state (red/green without text or icons)
333
- Generic "AI look" (purple gradients, oversized cards, stock layouts)
334
335
## Verification
336
337
After building UI, check what you can with the project's own tooling, and review the rest against this list. Don't add dependencies or install toolchains only to verify; say which checks you couldn't run.
338
339
- [ ] Component renders without console errors
340
- [ ] All interactive elements are keyboard accessible (Tab through the page)
341
- [ ] Screen reader can convey the page's content and structure
342
- [ ] Responsive: works at 320px, 768px, 1024px, 1440px
343
- [ ] Loading, empty, error, success, and permission states handled when applicable
344
- [ ] Follows the project's design system (spacing, colors, typography)
345
- [ ] The rendered result passes a final UI-specific finish-gate review
346
- [ ] No accessibility warnings in dev tools or axe-core
347

© Addy Osmani · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 10,802 prompts

More by @OpenSourceBuffGuy

See all
Playwright Integration Testing prompt image

Playwright Integration Testing

Sets Cursor up as a QA engineer who writes focused Playwright integration tests in TypeScript, mocking API routes and covering key user flows.

rule-file, cursor, playwright, typescript, testing, end-to-end-testing, best-practices, test-generation, for-developers, code, few-shot, guardrails, javascript, test-cases, api, act-as

Candid Portrait of Young Woman in Rainy Night Car prompt image

Candid Portrait of Young Woman in Rainy Night Car

Draws a candid flash-style portrait of a young woman in a car seat at night, with rain on the window and blurred city lights behind her.

image-prompt, json-prompt, photorealistic, woman, portrait, rain, night-scene, candid, smartphone-photo, bokeh, vertical-format, negative-prompt, moody, cityscape, cars, soft-lighting, close-up

Highlife-Inspired Afrobeats prompt image

Highlife-Inspired Afrobeats

Generates a joyful highlife-inspired Afrobeats song with clean guitar lines, brass stabs and storytelling lyrics at 112 BPM in D major.

music-prompt, afrobeats, genre-fusion, male-vocals, guitar, upbeat, music, music-production, for-musicians, song-structure, weddings, quick, suno

Reviews

Loading reviews…

Discussion

Loading comments…