React 19 + Next.js 16 + Tailwind CSS Best Practices
Comprehensive strict-rules reference for web apps built on React 19, the Next.js 16 App Router, and Tailwind CSS 4. Contains 34 rules across 6 categories. Each rule is stated as an Always/Never directive with a quantified impact, an incorrect example, and a correct example.
Stack Contract
All guidance assumes:
- React 19 with Server Components by default; Client Components only when interactivity is required (
'use client' at the top)
- Next.js 16 App Router with
app/ directory, layout.tsx, page.tsx, loading.tsx, error.tsx, not-found.tsx, parallel routes, intercepting routes
- Server Actions for mutations (
'use server') — never useEffect for data fetching
- Tailwind CSS 4 with the
@theme directive, dark: variant, container queries, and the standard 4pt spacing scale
- lucide-react as the canonical icon system
- No CSS-in-JS (no styled-components, no emotion) — Tailwind utility classes only, with
cn() from clsx + tailwind-merge for conditional classes
- shadcn/ui primitives (Radix-based) preferred for dialogs, popovers, dropdowns, tooltips, toasts
When to Apply
Reference these rules when:
- Building any user-facing route, layout, or component
- Reviewing PRs for design / UX / accessibility regressions
- Choosing between modality types (dialog vs popover vs full-page)
- Implementing forms with Server Actions and
useFormState / useOptimistic
- Configuring loading and error boundaries
- Designing onboarding, permissions, or settings flows
- Ensuring dark mode, focus management, and keyboard navigation work end-to-end
Rule Categories by Priority
| Priority |
Category |
Impact |
Prefix |
| 1 |
Navigation |
CRITICAL |
nav- |
| 2 |
Interaction Design |
CRITICAL |
inter- |
| 3 |
Accessibility |
CRITICAL |
acc- |
| 4 |
User Feedback |
HIGH |
feed- |
| 5 |
UX Patterns |
HIGH |
ux- |
| 6 |
Visual Design |
HIGH |
vis- |
Quick Reference
1. Navigation (CRITICAL)
nav-primary - Use top nav (3-7 sections) or sidebar; never hamburger-only on desktop
nav-app-router - Use App Router layouts, parallel routes, and <Link> for all internal navigation
nav-page-actions - Place primary actions in the page header; never bury them in scroll
2. Interaction Design (CRITICAL)
inter-touch-targets - 44×44 px minimum touch target (WCAG 2.5.5)
inter-pointer-patterns - Use standard hover/click/long-press patterns; never invent new ones
inter-microinteractions - Always confirm interaction with visual feedback within 100ms
inter-keyboard-navigation - Every interactive element must be reachable and operable by keyboard
inter-drag-drop - Provide a keyboard-accessible alternative whenever drag is offered
inter-revalidation - Use revalidatePath/revalidateTag after mutations; never rely on client refresh
inter-row-actions - Use a single "row action" pattern per list (kebab menu OR hover actions OR swipe)
inter-search - Debounce search input by 200-300ms and reflect query in the URL
3. Accessibility (CRITICAL)
acc-labels - Every interactive element has an accessible name
acc-text-scaling - All text scales to 200% browser zoom without horizontal scroll
acc-color-contrast - WCAG AA: 4.5:1 body text, 3:1 large/UI
acc-reduce-motion - Respect prefers-reduced-motion: reduce
acc-color-independent - Never rely on color alone to convey meaning
acc-focus-management - Always render a visible focus ring; trap focus inside modals
acc-relative-units - Use rem for text and spacing; never fix text size in px
acc-responsive-layout - Every layout works at 320 px width without horizontal scroll
4. User Feedback (HIGH)
feed-loading-states - Always use loading.tsx or <Suspense> with a skeleton matching final layout
feed-error-states - Every route segment has error.tsx with a Try-Again action
feed-toasts - Use toasts only for confirmations of non-blocking actions
feed-success-confirmation - Confirm every destructive or irreversible action with explicit visible feedback
feed-empty-states - Empty states explain why and offer the next action
5. UX Patterns (HIGH)
ux-onboarding - Onboarding never exceeds 3 screens; always skippable
ux-permissions - Request browser permissions in-context, not on page load
ux-modality - Choose dialog / popover / full-page by content weight; never stack modals
ux-destructive-confirmation - Destructive actions require a typed confirmation OR an undo window
ux-data-entry - Use Server Actions + progressive enhancement; never disable submit while typing
ux-undo - Prefer undo over confirmation for everyday actions
ux-settings - Settings are autosaved on change; never gated behind a Save button
6. Visual Design (HIGH)
vis-dark-mode - Use CSS custom properties + dark: variant; never hardcode text-black/bg-white
vis-icon-system - Use lucide-react with 1.5px stroke and size-4/size-5 standard sizes
vis-spacing - Use the Tailwind 4 pt scale and container queries; never use ad-hoc px margins
How to Use
Read individual reference files for detailed explanations and code examples:
- Section definitions - Category structure and impact levels
- Rule template - Template for adding new rules
Reference Files
| File |
Description |
| references/_sections.md |
Category definitions and ordering |
| assets/templates/_template.md |
Template for new rules |
1---2name: web-rules3description: Strict design and UX rules for React 19 + Next.js 16 (App Router) + Tailwind CSS 4. Covers navigation, interaction design, accessibility, user feedback, UX patterns, and visual design. Use when designing, building, or reviewing any user-facing web feature on this stack. Trigger when the user asks to "build a settings page", "add a dialog", "design this form", "review for accessibility", "fix dark mode", or any Next.js App Router / React 19 / Tailwind UI task. Also trigger when the user says output "looks off", "isn't accessible", or "doesn't follow best practices."4---5
6# React 19 + Next.js 16 + Tailwind CSS Best Practices
7
8Comprehensive strict-rules reference for web apps built on React 19, the Next.js 16 App Router, and Tailwind CSS 4. Contains 34 rules across 6 categories. Each rule is stated as an Always/Never directive with a quantified impact, an incorrect example, and a correct example.
9
10## Stack Contract
11
12All guidance assumes:
13
14- **React 19** with Server Components by default; Client Components only when interactivity is required (`'use client'` at the top)
15- **Next.js 16 App Router** with `app/` directory, `layout.tsx`, `page.tsx`, `loading.tsx`, `error.tsx`, `not-found.tsx`, parallel routes, intercepting routes
16- **Server Actions** for mutations (`'use server'`) — never `useEffect` for data fetching
17- **Tailwind CSS 4** with the `@theme` directive, `dark:` variant, container queries, and the standard 4pt spacing scale
18- **lucide-react** as the canonical icon system
19- **No CSS-in-JS** (no styled-components, no emotion) — Tailwind utility classes only, with `cn()` from `clsx` + `tailwind-merge` for conditional classes
20- **shadcn/ui primitives** (Radix-based) preferred for dialogs, popovers, dropdowns, tooltips, toasts
21
22## When to Apply
23
24Reference these rules when:
25
26- Building any user-facing route, layout, or component
27- Reviewing PRs for design / UX / accessibility regressions
28- Choosing between modality types (dialog vs popover vs full-page)
29- Implementing forms with Server Actions and `useFormState` / `useOptimistic`
30- Configuring loading and error boundaries
31- Designing onboarding, permissions, or settings flows
32- Ensuring dark mode, focus management, and keyboard navigation work end-to-end
33
34## Rule Categories by Priority
35
36| Priority | Category | Impact | Prefix |
37|----------|----------|--------|--------|
38| 1 | Navigation | CRITICAL | `nav-` |
39| 2 | Interaction Design | CRITICAL | `inter-` |
40| 3 | Accessibility | CRITICAL | `acc-` |
41| 4 | User Feedback | HIGH | `feed-` |
42| 5 | UX Patterns | HIGH | `ux-` |
43| 6 | Visual Design | HIGH | `vis-` |
44
45## Quick Reference
46
47### 1. Navigation (CRITICAL)
48
49- [`nav-primary`](references/nav-primary.md) - Use top nav (3-7 sections) or sidebar; never hamburger-only on desktop
50- [`nav-app-router`](references/nav-app-router.md) - Use App Router layouts, parallel routes, and `<Link>` for all internal navigation
51- [`nav-page-actions`](references/nav-page-actions.md) - Place primary actions in the page header; never bury them in scroll
52
53### 2. Interaction Design (CRITICAL)
54
55- [`inter-touch-targets`](references/inter-touch-targets.md) - 44×44 px minimum touch target (WCAG 2.5.5)
56- [`inter-pointer-patterns`](references/inter-pointer-patterns.md) - Use standard hover/click/long-press patterns; never invent new ones
57- [`inter-microinteractions`](references/inter-microinteractions.md) - Always confirm interaction with visual feedback within 100ms
58- [`inter-keyboard-navigation`](references/inter-keyboard-navigation.md) - Every interactive element must be reachable and operable by keyboard
59- [`inter-drag-drop`](references/inter-drag-drop.md) - Provide a keyboard-accessible alternative whenever drag is offered
60- [`inter-revalidation`](references/inter-revalidation.md) - Use `revalidatePath`/`revalidateTag` after mutations; never rely on client refresh
61- [`inter-row-actions`](references/inter-row-actions.md) - Use a single "row action" pattern per list (kebab menu OR hover actions OR swipe)
62- [`inter-search`](references/inter-search.md) - Debounce search input by 200-300ms and reflect query in the URL
63
64### 3. Accessibility (CRITICAL)
65
66- [`acc-labels`](references/acc-labels.md) - Every interactive element has an accessible name
67- [`acc-text-scaling`](references/acc-text-scaling.md) - All text scales to 200% browser zoom without horizontal scroll
68- [`acc-color-contrast`](references/acc-color-contrast.md) - WCAG AA: 4.5:1 body text, 3:1 large/UI
69- [`acc-reduce-motion`](references/acc-reduce-motion.md) - Respect `prefers-reduced-motion: reduce`
70- [`acc-color-independent`](references/acc-color-independent.md) - Never rely on color alone to convey meaning
71- [`acc-focus-management`](references/acc-focus-management.md) - Always render a visible focus ring; trap focus inside modals
72- [`acc-relative-units`](references/acc-relative-units.md) - Use `rem` for text and spacing; never fix text size in `px`
73- [`acc-responsive-layout`](references/acc-responsive-layout.md) - Every layout works at 320 px width without horizontal scroll
74
75### 4. User Feedback (HIGH)
76
77- [`feed-loading-states`](references/feed-loading-states.md) - Always use `loading.tsx` or `<Suspense>` with a skeleton matching final layout
78- [`feed-error-states`](references/feed-error-states.md) - Every route segment has `error.tsx` with a Try-Again action
79- [`feed-toasts`](references/feed-toasts.md) - Use toasts only for confirmations of non-blocking actions
80- [`feed-success-confirmation`](references/feed-success-confirmation.md) - Confirm every destructive or irreversible action with explicit visible feedback
81- [`feed-empty-states`](references/feed-empty-states.md) - Empty states explain why and offer the next action
82
83### 5. UX Patterns (HIGH)
84
85- [`ux-onboarding`](references/ux-onboarding.md) - Onboarding never exceeds 3 screens; always skippable
86- [`ux-permissions`](references/ux-permissions.md) - Request browser permissions in-context, not on page load
87- [`ux-modality`](references/ux-modality.md) - Choose dialog / popover / full-page by content weight; never stack modals
88- [`ux-destructive-confirmation`](references/ux-destructive-confirmation.md) - Destructive actions require a typed confirmation OR an undo window
89- [`ux-data-entry`](references/ux-data-entry.md) - Use Server Actions + progressive enhancement; never disable submit while typing
90- [`ux-undo`](references/ux-undo.md) - Prefer undo over confirmation for everyday actions
91- [`ux-settings`](references/ux-settings.md) - Settings are autosaved on change; never gated behind a Save button
92
93### 6. Visual Design (HIGH)
94
95- [`vis-dark-mode`](references/vis-dark-mode.md) - Use CSS custom properties + `dark:` variant; never hardcode `text-black`/`bg-white`
96- [`vis-icon-system`](references/vis-icon-system.md) - Use lucide-react with `1.5px` stroke and `size-4`/`size-5` standard sizes
97- [`vis-spacing`](references/vis-spacing.md) - Use the Tailwind 4 pt scale and container queries; never use ad-hoc `px` margins
98
99## How to Use
100
101Read individual reference files for detailed explanations and code examples:
102
103- [Section definitions](references/_sections.md) - Category structure and impact levels
104- [Rule template](assets/templates/_template.md) - Template for adding new rules
105
106## Reference Files
107
108| File | Description |
109|------|-------------|
110| [references/_sections.md](references/_sections.md) | Category definitions and ordering |
111| [assets/templates/_template.md](assets/templates/_template.md) | Template for new rules |