shadcn Dark Mode Broken by AI-Generated Hardcoded Colors
Dark mode unreadable from AI-generated shadcn components? Prevent design token drift with automated compliance checks and avoid white-on-white bugs..
20+ years shipping production JavaScript and front-end systems at scale. Lessons pulled from things that broke in production.
- ✓Deep production experience
- ✓Understanding of internals and trade-offs
- ✓Experience debugging complex systems
- Combine v0.dev (generation + Design Mode) with Cursor (Agent mode + .cursorrules) to scaffold shadcn/ui components in minutes instead of hours
- Biggest risk: AI defaults to hardcoded Tailwind classes that break dark mode and custom themes — enforce semantic tokens at every step
- Treat every AI output as a first draft, not a finished component
shadcn/ui is a collection of React components built on top of Radix UI primitives and styled with Tailwind CSS. Unlike traditional component libraries that ship precompiled CSS with hardcoded color values, shadcn components use CSS custom properties (CSS variables) for theming.
This design choice is what enables seamless dark mode toggling: when you switch themes, Tailwind's dark: variant or a class-based toggle updates the CSS variable values, and every component re-renders with the new colors automatically. The entire system depends on colors being defined as variables like --primary or --background rather than literal hex codes like #3b82f6.
When AI code generators like v0.dev or Cursor produce shadcn components, they frequently bypass this variable system and inject hardcoded Tailwind utility classes with literal color values (e.g., bg-blue-500 or text-gray-900). This breaks dark mode because those utilities don't reference the CSS variables that change with theme toggling.
The result is a component that looks correct in light mode but retains its light-mode colors when the user switches to dark mode — a common failure point that's invisible during initial development but immediately obvious in production.
The fix requires enforcing a strict specification: every color in every component must use CSS variable-based Tailwind classes (like bg-background or text-foreground) or custom utility classes that map to theme variables. For a project with 50+ components, this means building a specification system that AI tools can follow, combined with automated quality gates — typically a linting rule or a visual regression test — that rejects any component containing hardcoded color values.
Without this discipline, AI-generated shadcn components are effectively single-theme components that will fail in production environments where dark mode is expected.
Think of it like a factory assembly line. v0.dev is the machine that stamps out the raw part from a blueprint — and lets you tweak it visually in Design Mode before it leaves the press. Cursor is the engineer who reshapes and wires that part to fit the specific machine it's going into, using Agent mode and project rules to handle structural adaptation, not cosmetic touch-ups. Neither alone produces a finished component. Together they scale production from one component per hour to eight or more.
| Chrome | Firefox | Safari | Edge |
|---|---|---|---|
| ✓ | ✓ | ✓ | ✓ |
Building shadcn components by hand for a 50-component design system is slow and error-prone. AI generation promises speed, but it consistently breaks dark mode, misaligns with your theme tokens, and creates inconsistent code across dozens of files. This article walks you through a two-tool workflow—v0.dev for rapid generation and Cursor for surgical customization—so you can ship scalable, dark-mode-safe shadcn components without rewriting everything from scratch.
Why AI-Generated shadcn Components Break Dark Mode
AI code generators often produce shadcn components with hardcoded color values like #ffffff or bg-white instead of leveraging CSS variables such as bg-background or text-foreground. This bypasses the theming system that shadcn/ui relies on to toggle between light and dark modes. The result: components that look correct in one mode but become unreadable or visually broken when the user switches themes.
When you generate a shadcn component via an AI tool, the model typically outputs inline Tailwind classes or raw hex codes based on its training data. It does not understand that shadcn's architecture uses CSS custom properties defined in globals.css — variables like --background, --foreground, --card, etc. — which are dynamically swapped by a dark-mode class on <html>. Hardcoded colors ignore these variables, so they never respond to theme changes. This is a structural mismatch, not a cosmetic bug.
Use AI generation for shadcn components only when you explicitly instruct the model to reference theme variables (e.g., "use bg-background instead of bg-white") and then manually audit every color-related class. In production, this matters because dark mode is not optional — it's an accessibility and user preference requirement. A single hardcoded color in a critical component (like a modal or toast) can make your app unusable for dark-mode users, eroding trust and increasing support tickets.
fill="#1f2937" — the chart was invisible in dark mode because the fill matched the background.bg-white, text-black, and hex codes with shadcn's CSS variable classes.The Two-Tool Workflow: v0.dev and Cursor
This workflow uses each tool for the phase where it excels. Trying to do everything in one tool produces worse results and slower output.
v0.dev handles initial generation. It translates structured text prompts into functional React components using shadcn/ui primitives and Tailwind CSS. In 2026 it also offers Design Mode — a visual editor that lets you tweak layout, spacing, and color directly in the interface before exporting code. This removes a category of small fixes that previously required a Cursor round-trip.
Cursor handles contextualization. Its AI features — Chat with @codebase context, Agent and Composer mode for multi-file autonomous edits, inline Cmd+K transformations, and .cursorrules for project-wide rule enforcement — adapt generic v0.dev output to your project's design tokens, existing hooks, type definitions, and coding conventions.
The developer's role is quality control. You write the spec, review the generated scaffold, direct the refactoring, and sign off before merge. The AI handles the mechanical labor; you handle the judgment calls.
// Conceptual pipeline — illustrates the workflow stages // v0.dev and Cursor do not expose programmatic APIs; this is a process diagram in code form interface ComponentSpec { name: string; // PascalCase: UserAvatar, MetricCard, DataTable description: string; // One sentence: what it does, not how it looks props: PropSpec[]; variants: VariantSpec[]; states: string[]; // Always include: loading, error, empty isServerComponent: boolean; // React 19: explicit decision required } interface PipelineStage { tool: 'v0.dev' | 'cursor' | 'developer'; input: string; output: string; qualityCheck: string; } const pipeline: PipelineStage[] = [ { tool: 'developer', input: 'Product requirement or design file', output: 'ComponentSpec — structured definition of props, variants, states', qualityCheck: 'Does the spec describe one cohesive component, or should it be split?', }, { tool: 'v0.dev', input: 'ComponentSpec converted to a structured prompt', output: 'React component scaffold with Tailwind classes and TypeScript types', qualityCheck: 'Does it render? Are hardcoded colors present? Check Design Mode for layout issues.', }, { tool: 'cursor', input: 'v0.dev scaffold pasted into project', output: 'Project-native component using design tokens, existing hooks, and proper types', qualityCheck: 'Does tsc --noEmit pass? Does it render correctly in light and dark mode?', }, { tool: 'developer', input: 'Cursor-adapted component', output: 'Reviewed, tested, and merged component with Storybook story', qualityCheck: 'All four quality gates passed. PR approved.', }, ];
- v0.dev output is a first draft — assume 30 to 50 percent of it needs modification even after Design Mode adjustments.
- Cursor is the structural adaptation tool — it aligns generic output to project-specific context via Agent mode and .cursorrules.
- The developer is the quality gate — no AI output ships without human review of every line.
- Speed comes from repeating the loop efficiently, not from skipping review steps.
Phase 1: Generation with v0.dev
v0.dev translates structured UI descriptions into functional React components. Prompt quality directly determines output quality — a vague prompt produces a vague component that requires extensive rework.
A strong v0.dev prompt includes: the component name, one sentence describing its core function, the key props it accepts, the variants it supports, the states it must handle, the specific shadcn/ui primitives to use, and explicit token requirements.
After initial generation, use Design Mode to fix obvious visual issues — padding, spacing, color, layout — before exporting. This takes two to three minutes and removes a round of Cursor work.
v0.dev output is complete enough to run but not complete enough to ship. It will have hardcoded colors, generic types, and no connection to your project's hooks or utilities. That is expected. That is what Phase 2 addresses.
Create a shadcn/ui {COMPONENT_NAME} component with the following requirements: Core function: {ONE_SENTENCE — what it does, not how it looks} Props: - {PROP_NAME}: {TYPE} — {ONE_LINE_DESCRIPTION} - {PROP_NAME}: {TYPE} — {ONE_LINE_DESCRIPTION} - {PROP_NAME}: {TYPE} (optional) — {ONE_LINE_DESCRIPTION} Variants: - {VARIANT_NAME}: {OPTION_1} | {OPTION_2} | {OPTION_3} - size: sm | md | lg States to handle: - loading: show a Skeleton placeholder - error: show an inline error message with retry option - empty: show an empty state with a descriptive message Technical requirements: - Use these shadcn/ui primitives: {LIST — e.g., Card, Button, Badge, Skeleton} - Style exclusively with semantic color tokens: bg-primary, text-muted-foreground, border-border, text-foreground, bg-muted (Tailwind v4 @theme tokens — no hardcoded scales) - All props must have explicit TypeScript types — no any - Export the component as a named export - Include a Props interface above the component definition - {IF CLIENT COMPONENT}: Add 'use client' directive at top - {IF SERVER COMPONENT}: No useState or useEffect — accept data as props
Phase 2: Customization with Cursor
Cursor transforms the v0.dev scaffold into a project-native component through three steps: contextualize, refactor, and validate.
Step 1 — Contextualize. Paste the v0.dev output into your project at the correct file path. Open Cursor Chat and provide context using @codebase, or explicitly reference key files: @src/styles/globals.css (for Tailwind v4 @theme tokens), @src/types/user.ts, @src/hooks/useDataTable.ts. The more precise the context, the better the adaptation.
Step 2 — Refactor. Use Cmd+K for inline targeted changes or Agent mode for multi-step transformations. Common refactoring commands are shown in the code block below. If you have a .cursorrules file, it enforces project conventions automatically — semantic token usage, import patterns, naming conventions — reducing the number of manual corrections needed.
Step 3 — Validate. Run tsc --noEmit. Render the component in both light and dark mode. Check the output of the hardcoded color audit script. Do not proceed to the quality gates until these three checks pass.
// Cursor refactoring sequence — use these as Cmd+K prompts or Agent mode instructions // Run them in order for consistent results // Step 1: Token compliance // "Replace all hardcoded Tailwind color classes with semantic tokens. // Reference the @theme block in src/styles/globals.css for available token names. // Do not use bg-white, text-gray-*, bg-gray-*, or any raw color scale." // Step 2: Hook integration // "Replace the local useState and useEffect data fetching logic with our // custom useDataTable hook from @/hooks/useDataTable. // The hook accepts: { data, pageSize, sortable, filterable }. // It returns: { rows, pagination, sort, filter, isLoading, error }." // Step 3: Type alignment // "Replace the generic Row type with the TableRow interface from @/types/table.ts. // Replace any with the specific types from that file. // Run tsc --noEmit after changes to confirm no type errors." // Step 4: State handling // "Add loading state using our Skeleton component from @/components/ui/skeleton. // Add error state using our Alert component with a retry button. // Add empty state with an EmptyState component showing the emptyMessage prop." // Step 5: Server/client boundary (React 19) // "Evaluate whether this component requires 'use client'. // If it only receives data via props and has no browser-only APIs, // remove 'use client' and convert to a server component." // Step 6: Variant extraction // "Using the base component above as the default variant, // create a compact variant that reduces row padding to py-1 // and hides the checkbox selection column. // Export it as DataTableCompact from the same file." // After all steps, the component should: // - Import from project barrel exports, not direct component paths // - Use semantic color tokens exclusively // - Delegate state management to useDataTable // - Handle loading, error, and empty states // - Pass tsc --noEmit with zero errors // - Render correctly in light and dark mode
Scaling to 50+ Components: The Specification System
Generating one component is a technique. Generating fifty consistently is a system. The difference is the Component Specification Document.
Before generating any component, define every component in a structured spec. For each component: name, one-sentence description, key props (three to five), variant options, required states, and whether it is a server or client component. This document becomes your prompt source and your living documentation.
The batch process is sequential and repeatable: spec → prompt → v0.dev generation → Design Mode review → Cursor refactor → quality gate → Storybook story → merge. Each component follows the same pipeline. Variation in output quality comes from variation in spec quality — not from the tools.
In our six-hour session generating 52 components, two engineers worked in parallel on separate component groups. One handled data display components (tables, charts, stat cards); the other handled form inputs and navigation. Parallel execution is possible because each component is self-contained and the pipeline is the same for both.
// Component Specification Schema // Every component is defined here before generation begins // This file is reviewed once; the generated component is reviewed once // Both together take less time than manual component creation interface PropSpec { name: string; type: string; required: boolean; description: string; defaultValue?: string; } interface VariantSpec { name: string; // e.g., "size", "status", "density" options: string[]; // e.g., ["sm", "md", "lg"] default: string; } interface ComponentSpec { name: string; // PascalCase description: string; // One sentence — what it does props: PropSpec[]; variants: VariantSpec[]; states: string[]; // loading, error, empty — always all three shadcnPrimitives: string[]; // Exact primitives to reference in the prompt isServerComponent: boolean; // React 19: explicit decision before generation storybook: boolean; // Always true — every component gets a story } // Example specs const componentSpecs: ComponentSpec[] = [ { name: 'DataTable', description: 'Sortable, filterable table with pagination and row selection', props: [ { name: 'data', type: 'T[]', required: true, description: 'Array of row data objects' }, { name: 'columns', type: 'ColumnDef<T>[]', required: true, description: 'Column configuration array' }, { name: 'onRowSelect', type: '(rows: T[]) => void', required: false, description: 'Callback fired when row selection changes' }, { name: 'emptyMessage', type: 'string', required: false, defaultValue: 'No results found', description: 'Message shown in empty state' }, ], variants: [ { name: 'density', options: ['compact', 'default', 'comfortable'], default: 'default' }, ], states: ['loading', 'error', 'empty'], shadcnPrimitives: ['Table', 'Checkbox', 'Button', 'Skeleton', 'Alert'], isServerComponent: false, // Requires interactivity for sorting and selection storybook: true, }, { name: 'MetricCard', description: 'Displays a single KPI metric with label, value, trend indicator, and comparison period', props: [ { name: 'label', type: 'string', required: true, description: 'Metric name' }, { name: 'value', type: 'string | number', required: true, description: 'Current metric value' }, { name: 'trend', type: "'up' | 'down' | 'neutral'", required: false, description: 'Trend direction vs comparison period' }, { name: 'trendValue', type: 'string', required: false, description: 'e.g., "+12.4%" — shown next to trend indicator' }, ], variants: [ { name: 'size', options: ['sm', 'md', 'lg'], default: 'md' }, ], states: ['loading', 'error', 'empty'], shadcnPrimitives: ['Card', 'CardHeader', 'CardContent', 'Skeleton'], isServerComponent: true, // Display only — no interactivity required storybook: true, }, ];
- A structured spec produces consistent components across the entire library because each prompt follows the same pattern.
- Without specs, each generated component drifts toward a different pattern depending on how the prompt was written.
- Specs serve as living documentation — they answer 'why does this component have these props?' without reading the implementation.
- The spec review is the cheapest review in the pipeline. Catch structural problems here, not after generation.
Quality Gates: The Non-Negotiable Checkpoint
Automation without quality gates multiplies technical debt at the same rate it accelerates production. Each of the four gates targets a distinct failure mode that AI generation introduces.
Gate 1 — Visual regression. Render the component in Storybook across all variants and all states (loading, error, empty, populated). Check both light and dark mode. Screenshot comparison catches layout breaks that look fine in isolation but break in composition.
Gate 2 — Accessibility audit. Run axe-core against the component in the browser or Storybook. AI-generated components miss ARIA labels, keyboard navigation, and focus management at a high rate. This gate is not optional — it is a legal requirement in many jurisdictions.
Gate 3 — Integration test with real data. Mock data hides edge cases that production data exposes: long strings, null values, empty arrays, deeply nested objects. Connect the component to your actual API or a fixture that mirrors production data shape.
Gate 4 — Bundle size check. AI sometimes suggests heavy dependencies for problems that have lightweight solutions. A generated table component should not pull in a full charting library. Measure the bundle impact of each component before merge.
For simple presentational components (cards, badges, alerts), all four gates take eight to ten minutes. For complex interactive components (data tables, multi-step forms), they take twenty to thirty minutes. That time is not optional — it is the price of sustainable speed.
// Quality gate runner — run before any generated component is merged // Requires: Storybook running, dev server running, tsc available interface QualityReport { componentName: string; passed: boolean; failures: string[]; warnings: string[]; } async function runQualityGates(componentPath: string, componentName: string): Promise<QualityReport> { const report: QualityReport = { componentName, passed: true, failures: [], warnings: [], }; console.log(`\nRunning quality gates for ${componentName}...`); // Gate 1: TypeScript check // Run before visual checks — type errors indicate structural problems const typeCheckPassed = await runCommand(`npx tsc --noEmit --strict ${componentPath}`); if (!typeCheckPassed) { report.failures.push('Gate 1 failed: TypeScript type errors detected. Run tsc --noEmit to see full output.'); } // Gate 2: Visual regression — requires Storybook // Checks both light and dark mode renders for all variants const visualPassed = await runVisualRegression(componentName); if (!visualPassed) { report.failures.push('Gate 2 failed: Visual regression detected. Check Storybook screenshots for diff.'); } // Gate 3: Accessibility audit — requires dev server // Target the Storybook story URL for the component const storybookUrl = `http://localhost:6006/iframe.html?id=${componentName.toLowerCase()}--default`; const a11yViolations = await runCommand( `npx @axe-core/cli "${storybookUrl}" --tags wcag2a,wcag2aa --exit` ); if (!a11yViolations) { report.failures.push('Gate 3 failed: Accessibility violations found. Run axe-core manually to see full report.'); } // Gate 4: Hardcoded color audit const colorAuditPassed = await runCommand( `! grep -rn -e 'bg-white' -e 'bg-black' -e 'text-gray-[0-9]' -e 'bg-gray-[0-9]' ${componentPath}` ); if (!colorAuditPassed) { report.failures.push('Gate 4 failed: Hardcoded color classes detected. Replace with semantic tokens.'); } // Gate 5: Bundle size impact // Warning if over 5KB, failure if over 20KB for a single component const bundleImpactKB = await measureBundleImpact(componentPath); if (bundleImpactKB > 20) { report.failures.push(`Gate 5 failed: Component adds ${bundleImpactKB}KB to bundle. Investigate imports.`); } else if (bundleImpactKB > 5) { report.warnings.push(`Gate 5 warning: Component adds ${bundleImpactKB}KB. Review imports for tree-shaking opportunities.`); } report.passed = report.failures.length === 0; if (report.passed) { console.log(`✓ ${componentName} passed all quality gates`); if (report.warnings.length > 0) { console.log(` Warnings: ${report.warnings.join(', ')}`); } } else { console.log(`✗ ${componentName} failed ${report.failures.length} gate(s):\n ${report.failures.join('\n ')}`); } return report; }
Version Control and Team Workflow at Scale
Generating 50+ components creates a version control and review workflow problem. Without a clear branching and commit strategy, the PR queue becomes unmanageable and review quality drops.
We used a component-group branching strategy: one feature branch per logical group of components (data-display, form-inputs, navigation, feedback). Each branch contained six to ten related components. This kept PR diffs reviewable and allowed parallel work without merge conflicts.
Commit strategy within each branch: one commit per component, with a consistent message format. This makes bisecting straightforward if a component introduces a regression.
Review strategy: the author runs all quality gates locally before opening the PR. The reviewer checks only that the gates passed (via CI output) and does a spot-check on one component's light and dark mode rendering. With quality gates in CI, the reviewer is not re-checking mechanical compliance — they are checking judgment calls.
#!/bin/bash # Component generation workflow — run these commands in sequence # Assumes: main branch is clean, Storybook is configured COMPONENT_NAME=$1 GROUP=$2 # e.g., data-display, form-inputs, navigation if [ -z "$COMPONENT_NAME" ] || [ -z "$GROUP" ]; then echo "Usage: ./component-workflow.sh ComponentName group-name" exit 1 fi # Step 1: Ensure you are on the correct feature branch BRANCH="feat/components-${GROUP}" git checkout "$BRANCH" 2>/dev/null || git checkout -b "$BRANCH" echo "Branch: $BRANCH" echo "Ready to generate: $COMPONENT_NAME" echo "" echo "Workflow:" echo "1. Open v0.dev — paste spec prompt — review in Design Mode — copy output" echo "2. Create file: src/components/${COMPONENT_NAME}.tsx" echo "3. Paste v0.dev output" echo "4. Open Cursor — run refactoring sequence (see Phase 2 prompts)" echo "5. Run type check:" echo " npx tsc --noEmit" echo "6. Run color audit:" echo " grep -rn -e 'bg-white' -e 'text-gray-[0-9]' src/components/${COMPONENT_NAME}.tsx" echo "7. Generate Storybook story with Cursor Agent mode" echo "8. Verify in Storybook: light mode, dark mode, all variants, all states" echo "9. Commit:" echo " git add src/components/${COMPONENT_NAME}.tsx src/components/${COMPONENT_NAME}.stories.tsx" echo " git commit -m 'feat(components): add ${COMPONENT_NAME} — ${GROUP} group'" echo "10. Next component — repeat from step 1"
Common Failure Modes at Scale
After generating components in volume, specific failure patterns become predictable. These are the five most common issues we hit and have seen other teams hit.
- A single Button with five variants is easier to maintain than five separate button components.
- A single Card with size and density variants covers most display use cases without proliferation.
- Track your component count against your spec count. If components grow faster than specs, you have sprawl.
- Use Cursor Agent mode to refactor sprawl: 'Merge ButtonSmall, ButtonLarge, and ButtonIcon into a single Button component with size and icon variant props.'
Stop Copy-Pasting: The Real Power Is AI That Understands Your Design Tokens
Most tutorials show you how to generate a shadcn button with AI. That's table stakes. The real unlock is teaching your AI to read your design tokens before it writes a single line of JSX. Your tailwind.config.ts and CSS variables are a contract. If your AI doesn't respect them, every generated component introduces drift. I've seen teams burn two weeks fixing mismatched border radii because the AI hallucinated rounded-xl while the spec said rounded-lg. The fix is brutal but effective: inject your token map into every prompt. Store it as a JSON file in your project root. Reference it like a config. When v0.dev generates a component, it should match your tokens within 95% accuracy on the first pass. The remaining 5% gets caught in Cursor. This isn't about generating faster. It's about generating correctly. One prompt with tokens beats ten prompts without.
// io.thecodeforge.ai/shadcn-tokens === 0.3.2 // Inject this into every v0.dev prompt export const designTokens = { radius: { sm: '4px', md: '6px', lg: '8px', xl: '12px', }, spacing: { xs: '4px', sm: '8px', md: '16px', lg: '24px', xl: '32px', }, colors: { primary: { DEFAULT: 'hsl(222.2 47.4% 11.2%)', foreground: 'hsl(210 40% 98%)', }, muted: { DEFAULT: 'hsl(210 40% 96.1%)', foreground: 'hsl(215.4 16.3% 46.9%)', }, }, } as const; // Expected output from AI: consistent border radius read from token, not hardcoded
rounded-[5px]. That bypasses your design system entirely. If you see this in a generated component, delete it. The next developer will blame you when the UI looks like a Frankenstein project.The Prompt Is Your Weakest Link: Write Specs, Not Wishes
Vague prompts produce broken components. I've watched senior engineers type 'generate a data table' and then spend an hour fixing the generated mess. The AI doesn't read minds. It reads words. If you don't specify loading states, empty states, error states, and pagination behavior, you'll get a generic table that looks good in a demo and fails in production. Here's the pattern that works: treat your prompt like a spec document. List every prop, every state, every edge case. Use bullet points. Include your TypeScript interface. Reference the exact shadcn variant you want. For a combobox, that means specifying whether it's single-select or multi-select, whether search is client-side or server-side, and what happens when the user types a value not in the list. My team reduced post-generation rework by 60% just by adopting this prompt structure. The AI generates the first draft. You generate the spec.
<!-- io.thecodeforge.ai/prompt-spec === 0.1.0 --> Generate a shadcn Combobox component with: **Props Interface:** - options: Array<{ label: string; value: string }> - placeholder?: string (default: 'Select...') - onSelect: (value: string) => void - loading?: boolean - error?: string **States:** 1. Default: show placeholder 2. Open dropdown: filterable search input visible 3. Empty state: 'No results found' centered in dropdown 4. Loading: spinner inside dropdown 5. Error: red text below input 6. Selected: show selected label, hide placeholder **Behavior:** - Close dropdown on outside click - Keyboard navigation: arrow keys, Enter to select - Escape closes dropdown without selecting
prompt-library/ folder in your repo. Next sprint, when you need a Dialog component, you don't start from scratch. You clone the Modald spec and swap the variants. Your AI toolchain becomes a reusable asset, not a one-off party trick.The Design Token Drift Incident
- Never trust AI output to use your design tokens correctly — v0.dev defaults to generic Tailwind classes regardless of what you specify in your prompt.
- Automate design system compliance checks before merging any generated component. A shell script or ESLint rule catches what code review misses.
- Test every generated component in both light and dark mode before marking it done. Add this to your PR checklist, not your memory.
- In Tailwind v4, your semantic tokens are defined in your CSS file under @theme — make sure your audit scripts and AI prompts reference the correct location.
use() is more appropriate than useEffect for the data fetching pattern.grep -rn -e 'bg-white' -e 'bg-black' -e 'text-gray-[0-9]' -e 'bg-gray-[0-9]' src/components/ --include='*.tsx'grep -rn -e 'bg-blue-[0-9]' -e 'bg-red-[0-9]' -e 'bg-green-[0-9]' -e 'text-black' src/components/ --include='*.tsx'npx @next/bundle-analyzergrep -rn "from 'lodash'" src/components/ --include='*.tsx'npx @axe-core/cli http://localhost:3000/component-preview --tags wcag2a,wcag2aagrep -rn 'onClick' src/components/ --include='*.tsx' | grep -v 'onKeyDown'npx tsc --noEmit --strict src/components/YourComponent.tsxgrep -rn ': any' src/components/YourComponent.tsx| Capability | v0.dev | Cursor |
|---|---|---|
| Initial generation from prompt | Strong — produces styled, functional React components from structured text prompts | Not designed for this — use v0.dev for generation from scratch |
| Visual polishing before code export | Strong — Design Mode provides a visual editor for layout, spacing, and color adjustments | Not applicable — Cursor works on code, not visual previews |
| Project contextualization | Limited — output is generic; does not know your hooks, types, or token definitions | Strong — @codebase context, explicit file references, Agent mode, and .cursorrules adapt output to project conventions |
| Design token compliance | Poor — defaults to hardcoded Tailwind color scales regardless of prompt instructions | Strong — can audit and replace hardcoded colors via Cmd+K or Agent mode with explicit token references |
| Variant generation | Moderate — requires separate prompts; Design Mode helps with visual variants | Strong — Agent mode generates variants from the base component in a single instruction |
| TypeScript type refinement | Basic — generates plausible types that may not match your data models | Strong — aligns generated types with existing project interfaces when given explicit file references |
| Multi-file batch refactoring | Not supported — one component output at a time | Strong — Agent mode handles changes across multiple files in a single session |
| Storybook story generation | Not supported | Strong — Agent mode generates complete Storybook v8 story files from the component and fixture data |
| Accessibility remediation | Not supported — no a11y audit or fix capability | Strong — Agent mode adds ARIA attributes and keyboard handlers when given explicit WCAG instructions |
| Learning curve | Low — prompt-based interface with visual Design Mode fallback | Medium — requires understanding of @codebase context, Agent mode workflow, and .cursorrules configuration |
| File | Command / Code | Purpose |
|---|---|---|
| src | interface ComponentSpec { | The Two-Tool Workflow |
| v0-prompt-template.txt | Create a shadcn/ui {COMPONENT_NAME} component with the following requirements: | Phase 1 |
| src | interface PropSpec { | Scaling to 50+ Components |
| scripts | interface QualityReport { | Quality Gates |
| scripts | COMPONENT_NAME=$1 | Version Control and Team Workflow at Scale |
| design-tokens.ts | export const designTokens = { | Stop Copy-Pasting |
| prompt-spec.md | The Prompt Is Your Weakest Link |
Key takeaways
Common mistakes to avoid
6 patternsPrompting v0.dev for logic instead of presentation
Ignoring design token requirements in the prompt
Not validating AI-generated TypeScript types against project models
Creating new components when a variant would suffice
Skipping accessibility review because the component looks correct
Not generating Storybook stories alongside components
Interview Questions on This Topic
How would you design a system to automatically generate UI components that adhere to a company's design system?
What are the risks of using AI to generate code at scale, and how do you mitigate them?
A team generated 30 UI components with AI and shipped them. Two weeks later, dark mode is broken on 18 of them. Walk through how you would diagnose and fix this.
How do you handle the version control and review workflow when generating 50+ components in a short time period?
When would you not use AI generation for a UI component?
Frequently Asked Questions
Yes. The pipeline structure — spec, generate, contextualize, validate — applies to any component library. For Radix UI, Headless UI, Mantine, or custom component systems, adjust your v0.dev prompts to reference the correct primitives and your .cursorrules to enforce the correct import patterns. The quality gates are library-agnostic. The token compliance gate depends on your design system's implementation — update the grep patterns to match your token naming convention.
Generate the UI shell only — tell v0.dev explicitly to produce a presentational component that accepts data and callbacks via props. Then use Cursor Agent mode to extract any remaining state logic into a dedicated custom hook: useDataTable, useFormValidation, useModalState. The component renders; the hook manages state and side effects. This separation makes the component easier to test (mock the hook), reuse across different contexts, and replace without breaking the UI.
They can, and in predictable ways. AI-generated list and table components rarely include memoization. AI-generated form components often recreate handlers on every render. Common fixes: wrap row and cell components in React.memo, use useCallback for all event handlers passed as props, and virtualize any list exceeding 100 items with @tanstack/virtual. Profile with React DevTools Profiler before and after — look for components that render more than twice on a single state change. Performance is part of the integration test quality gate, not an afterthought.
For simple presentational components — cards, badges, stat displays, alert banners — eight to twelve per hour across the full pipeline including quality gates. For complex interactive components — data tables, multi-step forms, comboboxes, calendar inputs — three to five per hour. The bottleneck is the quality gate review, not the generation. A simple component takes two minutes to generate and eight to ten minutes to review, test, and integrate. A complex component takes three to five minutes to generate and twenty to thirty minutes to review properly. Do not measure progress by generation speed — measure it by components that have passed all quality gates.
Two practical changes. First, your design tokens are now defined in your CSS file under @theme, not in tailwind.config.ts. Update your v0.dev prompts, Cursor .cursorrules, and audit scripts to reference globals.css instead of tailwind.config.ts. Second, token names in @theme use CSS custom property syntax internally (--color-primary) but are referenced in Tailwind classes the same way (bg-primary, text-primary). Your semantic token class names do not change — only where they are defined. If you are migrating from Tailwind v3, the main work is moving token definitions from tailwind.config.ts to the @theme block and updating any direct references to the config file in your tooling.
Make the decision in the spec, before generation. For every component in your spec, add a boolean: isServerComponent. The rule is: if the component requires useState, useEffect, event handlers, or browser-only APIs, it is a client component and needs 'use client'. If it only receives data via props and renders it, it should be a server component. Make this explicit in your v0.dev prompt — either include 'add use client directive' or 'this is a server component — no useState or useEffect.' v0.dev defaults to client component patterns, so you must be explicit. After generation, Cursor Agent mode can convert a client component to a server component if the assessment changes during refactoring.
20+ years shipping production JavaScript and front-end systems at scale. Lessons pulled from things that broke in production.
That's React.js. Mark it forged?
6 min read · try the examples if you haven't