|
| 1 | +--- |
| 2 | +description: Review UI code for Vercel Web Interface Guidelines compliance |
| 3 | +argument-hint: <file-or-pattern> |
| 4 | +--- |
| 5 | + |
| 6 | +# Web Interface Guidelines |
| 7 | + |
| 8 | +Review these files for compliance: $ARGUMENTS |
| 9 | + |
| 10 | +Read files, check against rules below. Output concise but comprehensive—sacrifice grammar for brevity. High signal-to-noise. |
| 11 | + |
| 12 | +## Rules |
| 13 | + |
| 14 | +### Accessibility |
| 15 | + |
| 16 | +- Icon-only buttons need `aria-label` |
| 17 | +- Form controls need `<label>` or `aria-label` |
| 18 | +- Interactive elements need keyboard handlers (`onKeyDown`/`onKeyUp`) |
| 19 | +- `<button>` for actions, `<a>`/`<Link>` for navigation (not `<div onClick>`) |
| 20 | +- Images need `alt` (or `alt=""` if decorative) |
| 21 | +- Decorative icons need `aria-hidden="true"` |
| 22 | +- Async updates (toasts, validation) need `aria-live="polite"` |
| 23 | +- Use semantic HTML (`<button>`, `<a>`, `<label>`, `<table>`) before ARIA |
| 24 | +- Headings hierarchical `<h1>`–`<h6>`; include skip link for main content |
| 25 | +- `scroll-margin-top` on heading anchors |
| 26 | +- Meaningful media needs captions, transcripts, or descriptions as applicable |
| 27 | +- Media controls need keyboard support; decorative media needs assistive-tech hiding |
| 28 | + |
| 29 | +### Focus States |
| 30 | + |
| 31 | +- Interactive elements need visible focus: `focus-visible:ring-*` or equivalent |
| 32 | +- Never `outline-none` / `outline: none` without focus replacement |
| 33 | +- Use `:focus-visible` over `:focus` (avoid focus ring on click) |
| 34 | +- Group focus with `:focus-within` for compound controls |
| 35 | +- Sticky headers/footers/overlays must not cover the focused element |
| 36 | + |
| 37 | +### Forms |
| 38 | + |
| 39 | +- Inputs need `autocomplete` and meaningful `name` |
| 40 | +- Use correct `type` (`email`, `tel`, `url`, `number`) and `inputmode` |
| 41 | +- Never block paste (`onPaste` + `preventDefault`) |
| 42 | +- Labels clickable (`htmlFor` or wrapping control) |
| 43 | +- Disable spellcheck on emails, codes, usernames (`spellCheck={false}`) |
| 44 | +- Checkboxes/radios: label + control share single hit target (no dead zones) |
| 45 | +- Submit button stays enabled until request starts; spinner during request |
| 46 | +- Errors inline next to fields; focus first error on submit |
| 47 | +- Placeholders end with `…` and show example pattern |
| 48 | +- `autocomplete="off"` on non-auth fields to avoid password manager triggers |
| 49 | +- Warn before navigation with unsaved changes (`beforeunload` or router guard) |
| 50 | + |
| 51 | +### Animation |
| 52 | + |
| 53 | +- Honor `prefers-reduced-motion` (provide reduced variant or disable) |
| 54 | +- Animate `transform`/`opacity` only (compositor-friendly) |
| 55 | +- Never `transition: all`—list properties explicitly |
| 56 | +- Set correct `transform-origin` |
| 57 | +- SVG: transforms on `<g>` wrapper with `transform-box: fill-box; transform-origin: center` |
| 58 | +- Animations interruptible—respond to user input mid-animation |
| 59 | +- Autoplay motion >5 seconds alongside other content needs pause, stop, or hide controls |
| 60 | +- Muted decorative loops must stop under `prefers-reduced-motion` |
| 61 | + |
| 62 | +### Typography |
| 63 | + |
| 64 | +- `…` not `...` |
| 65 | +- Curly quotes `“` `”` not straight `"` |
| 66 | +- Non-breaking spaces: `10 MB`, `⌘ K`, brand names |
| 67 | +- Loading states end with `…`: `"Loading…"`, `"Saving…"` |
| 68 | +- `font-variant-numeric: tabular-nums` for number columns/comparisons |
| 69 | +- Use `text-wrap: balance` or `text-pretty` on headings (prevents widows) |
| 70 | + |
| 71 | +### Content Handling |
| 72 | + |
| 73 | +- Text containers handle long content: `truncate`, `line-clamp-*`, or `break-words` |
| 74 | +- Flex children need `min-w-0` to allow text truncation |
| 75 | +- Handle empty states—don't render broken UI for empty strings/arrays |
| 76 | +- User-generated content: anticipate short, average, and very long inputs |
| 77 | + |
| 78 | +### Images |
| 79 | + |
| 80 | +- `<img>` needs explicit `width` and `height` (prevents CLS) |
| 81 | +- Below-fold images: `loading="lazy"` |
| 82 | +- Above-fold critical images: `priority` or `fetchpriority="high"` |
| 83 | + |
| 84 | +### Performance |
| 85 | + |
| 86 | +- Large lists (>50 items): virtualize (`virtua`, `content-visibility: auto`) |
| 87 | +- No layout reads in render (`getBoundingClientRect`, `offsetHeight`, `offsetWidth`, `scrollTop`) |
| 88 | +- Batch DOM reads/writes; avoid interleaving |
| 89 | +- Prefer uncontrolled inputs; controlled inputs must be cheap per keystroke |
| 90 | +- Add `<link rel="preconnect">` for CDN/asset domains |
| 91 | +- Critical fonts: `<link rel="preload" as="font">` with `font-display: swap` |
| 92 | +- Prefer `<video autoplay muted loop playsinline>` over animated GIF; provide a still alternative |
| 93 | +- Short non-essential loops: Safari H.264 MP4 `<picture>` source, `prefers-reduced-motion` media condition, and still fallback |
| 94 | + |
| 95 | +### Navigation & State |
| 96 | + |
| 97 | +- URL reflects state—filters, tabs, pagination, expanded panels in query params |
| 98 | +- Links use `<a>`/`<Link>` (Cmd/Ctrl+click, middle-click support) |
| 99 | +- Deep-link all stateful UI (if uses `useState`, consider URL sync via nuqs or similar) |
| 100 | +- Destructive actions need confirmation modal or undo window—never immediate |
| 101 | + |
| 102 | +### Touch & Interaction |
| 103 | + |
| 104 | +- `touch-action: manipulation` (prevents double-tap zoom delay) |
| 105 | +- `-webkit-tap-highlight-color` set intentionally |
| 106 | +- `overscroll-behavior: contain` in modals/drawers/sheets |
| 107 | +- Page rubber-band suppression: `overscroll-behavior: none` on `<html>` inside `@media (pointer: fine)`; keep coarse-pointer page defaults for pull-to-refresh. Test hybrid touch devices: `pointer` describes the primary input, and `none` also disables scroll chaining and native swipe navigation |
| 108 | +- During drag: disable text selection, `inert` on dragged elements |
| 109 | +- Drag/swipe/pinch/path gestures need tap/click and keyboard alternatives unless essential |
| 110 | +- `autoFocus` sparingly—desktop only, single primary input; avoid on mobile |
| 111 | + |
| 112 | +### Safe Areas & Layout |
| 113 | + |
| 114 | +- Full-bleed layouts need `env(safe-area-inset-*)` for notches |
| 115 | +- Avoid unwanted scrollbars: `overflow-x-hidden` on containers, fix content overflow |
| 116 | +- Flex/grid over JS measurement for layout |
| 117 | + |
| 118 | +### Dark Mode & Theming |
| 119 | + |
| 120 | +- `color-scheme: dark` on `<html>` for dark themes (fixes scrollbar, inputs) |
| 121 | +- `<meta name="theme-color">` matches page background |
| 122 | +- Native `<select>`: explicit `background-color` and `color` (Windows dark mode) |
| 123 | + |
| 124 | +### Locale & i18n |
| 125 | + |
| 126 | +- Dates/times: use `Intl.DateTimeFormat` not hardcoded formats |
| 127 | +- Numbers/currency: use `Intl.NumberFormat` not hardcoded formats |
| 128 | +- Detect language via `Accept-Language` / `navigator.languages`, not IP |
| 129 | +- Brand names, code tokens, identifiers: wrap with `translate="no"` to prevent garbled auto-translation |
| 130 | + |
| 131 | +### Hydration Safety |
| 132 | + |
| 133 | +- Inputs with `value` need `onChange` (or use `defaultValue` for uncontrolled) |
| 134 | +- Date/time rendering: guard against hydration mismatch (server vs client) |
| 135 | +- `suppressHydrationWarning` only where truly needed |
| 136 | + |
| 137 | +### Hover & Interactive States |
| 138 | + |
| 139 | +- Buttons/links need `hover:` state (visual feedback) |
| 140 | +- Interactive states increase contrast: hover/active/focus more prominent than rest |
| 141 | + |
| 142 | +### Content & Copy |
| 143 | + |
| 144 | +- Active voice: "Install the CLI" not "The CLI will be installed" |
| 145 | +- Title Case for headings/buttons (Chicago style) |
| 146 | +- Numerals for counts: "8 deployments" not "eight" |
| 147 | +- Specific button labels: "Save API Key" not "Continue" |
| 148 | +- Error messages include fix/next step, not just problem |
| 149 | +- Second person; avoid first person |
| 150 | +- `&` over "and" where space-constrained |
| 151 | + |
| 152 | +### Anti-patterns (flag these) |
| 153 | + |
| 154 | +- `user-scalable=no` or `maximum-scale=1` disabling zoom |
| 155 | +- `onPaste` with `preventDefault` |
| 156 | +- `transition: all` |
| 157 | +- `outline-none` without focus-visible replacement |
| 158 | +- Inline `onClick` navigation without `<a>` |
| 159 | +- `<div>` or `<span>` with click handlers (should be `<button>`) |
| 160 | +- Images without dimensions |
| 161 | +- Large arrays `.map()` without virtualization |
| 162 | +- Form inputs without labels |
| 163 | +- Icon buttons without `aria-label` |
| 164 | +- Hardcoded date/number formats (use `Intl.*`) |
| 165 | +- `autoFocus` without clear justification |
| 166 | +- Animated GIF when compressed video is suitable |
| 167 | +- Gesture-only action without tap/click and keyboard alternative |
| 168 | + |
| 169 | +## Output Format |
| 170 | + |
| 171 | +Group by file. Use `file:line` format (VS Code clickable). Terse findings. |
| 172 | + |
| 173 | +```text |
| 174 | +## src/Button.tsx |
| 175 | +
|
| 176 | +src/Button.tsx:42 - icon button missing aria-label |
| 177 | +src/Button.tsx:18 - input lacks label |
| 178 | +src/Button.tsx:55 - animation missing prefers-reduced-motion |
| 179 | +src/Button.tsx:67 - transition: all → list properties |
| 180 | +
|
| 181 | +## src/Modal.tsx |
| 182 | +
|
| 183 | +src/Modal.tsx:12 - missing overscroll-behavior: contain |
| 184 | +src/Modal.tsx:34 - "..." → "…" |
| 185 | +
|
| 186 | +## src/Card.tsx |
| 187 | +
|
| 188 | +✓ pass |
| 189 | +``` |
| 190 | + |
| 191 | +State issue + location. Skip explanation unless fix non-obvious. No preamble. |
0 commit comments