Skip to main content
RapidDev - Software Development Agency
v0-issues

Ensuring TailwindCSS classes apply properly in v0 components

TailwindCSS classes fail to apply in V0 components primarily because of the Tailwind v3/v4 version mismatch when exporting code. V0 updated to Tailwind v4 in February 2026, but older projects and exports to create-next-app projects still hit this conflict. After export, verify your globals.css has the correct Tailwind directives, ensure the content paths in tailwind.config cover all component files, and use the cn() utility from lib/utils to merge conditional classes safely.

Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Beginner6 min read10-20 minutesV0 with Next.js App Router, Tailwind CSS v3/v4March 2026RapidDev Engineering Team
TL;DR

TailwindCSS classes fail to apply in V0 components primarily because of the Tailwind v3/v4 version mismatch when exporting code. V0 updated to Tailwind v4 in February 2026, but older projects and exports to create-next-app projects still hit this conflict. After export, verify your globals.css has the correct Tailwind directives, ensure the content paths in tailwind.config cover all component files, and use the cn() utility from lib/utils to merge conditional classes safely.

Why Tailwind classes stop working in V0 components

V0 generates Tailwind CSS classes that work perfectly in its preview sandbox. Problems appear after exporting the code to a local project or when mixing V0-generated code with an existing codebase. The most common cause is a Tailwind version mismatch: V0 historically used Tailwind v3.4.17 (updated to v4.2.0 in February 2026), while create-next-app defaults to Tailwind v4 with CSS-based configuration instead of tailwind.config.js. The two versions use different configuration formats and may not recognize the same utility classes.

  • Tailwind v3/v4 version mismatch between V0 export and the target project
  • Missing Tailwind directives in globals.css (@tailwind base; @tailwind components; @tailwind utilities;)
  • Content paths in tailwind.config.js not including V0 component directories
  • Dynamic class names constructed with template literals not picked up by Tailwind's class scanner
  • PostCSS configuration missing or misconfigured after export

Error messages you might see

warn - The `content` option in your Tailwind CSS configuration is missing or empty.

The tailwind.config.js content array does not include paths to your component files. Tailwind cannot find which classes to include in the build.

Unknown at rule @tailwind

Your IDE or PostCSS does not recognize Tailwind directives. Install the Tailwind CSS IntelliSense extension or verify PostCSS configuration.

The NextJS one you downloaded is 15.2.4 and the one you created is 15.3.3, Tailwind most likely be 4.1.4 (the one created) and 3.4.17 (the one downloaded)

Version mismatch between V0 export (Tailwind v3) and your local project (Tailwind v4). The configuration formats are incompatible.

Before you start

  • A V0 project or exported V0 code with styling issues
  • Access to project configuration files (globals.css, tailwind.config)
  • Basic understanding of Tailwind CSS utility classes

How to fix it

1

Verify Tailwind directives in globals.css

Without the @tailwind directives, no Tailwind utility classes will be included in the compiled CSS, making all Tailwind classes invisible.

Open app/globals.css and verify it contains the Tailwind directives at the top. For Tailwind v3, use @tailwind directives. For Tailwind v4, use @import "tailwindcss".

Before
typescript
/* globals.css — missing Tailwind directives */
body {
margin: 0;
font-family: sans-serif;
}
After
typescript
/* globals.css — Tailwind v3 */
@tailwind base;
@tailwind components;
@tailwind utilities;
/* OR for Tailwind v4 */
@import "tailwindcss";
body {
margin: 0;
font-family: sans-serif;
}

Expected result: All Tailwind utility classes like bg-blue-500, flex, p-4 apply correctly to elements.

2

Match Tailwind versions between V0 export and local project

Tailwind v3 uses tailwind.config.js with JavaScript configuration. Tailwind v4 uses CSS-based configuration and does not require a config file. Mixing them causes classes to be silently ignored.

Check your V0 export's package.json for the Tailwind version. If your local project uses a different major version, align them. The safest approach is to use the same version as the V0 export.

Before
typescript
// V0 export: tailwindcss v3.4.17 in package.json
// Local project: tailwindcss v4.1.4 from create-next-app
After
typescript
// Option 1: Downgrade local project to match V0
// In package.json: "tailwindcss": "^3.4.17"
// Option 2: Keep v4 and migrate config
// Remove tailwind.config.js
// Update globals.css: @import "tailwindcss";

Expected result: Both V0 code and local project use the same Tailwind version. All utility classes render correctly.

3

Configure content paths to include all component directories

Tailwind v3 scans files listed in the content array to determine which utility classes to include. If V0 components are in directories not listed, their classes are purged from the final CSS.

Open tailwind.config.js (Tailwind v3 only) and verify the content array includes all directories containing V0 components.

Before
typescript
// tailwind.config.js — missing component paths
module.exports = {
content: ['./app/**/*.{ts,tsx}'],
theme: { extend: {} },
};
After
typescript
// tailwind.config.js — all V0 paths included
module.exports = {
content: [
'./app/**/*.{ts,tsx}',
'./components/**/*.{ts,tsx}',
'./lib/**/*.{ts,tsx}',
],
theme: { extend: {} },
};

Expected result: Tailwind scans all component files. No utility classes are accidentally purged from the build.

4

Use the cn() utility for conditional class merging

V0 includes a cn() function in lib/utils.ts that safely merges Tailwind classes using clsx and tailwind-merge. This prevents conflicting classes from producing unexpected results.

Import cn from lib/utils and use it whenever you combine multiple class sources or conditional classes. For projects with extensive conditional styling needs, RapidDev can help implement a design system with consistent Tailwind patterns.

Before
typescript
// Conflicting classes — unpredictable result
<div className={`p-4 ${isActive ? 'bg-blue-500 p-6' : 'bg-gray-100'}`}>
Content
</div>
After
typescript
import { cn } from '@/lib/utils';
<div className={cn('p-4', isActive ? 'bg-blue-500 p-6' : 'bg-gray-100')}>
Content
</div>

Expected result: When isActive is true, p-6 overrides p-4 cleanly. tailwind-merge resolves the conflict correctly.

Complete code example

lib/utils.ts
1import { type ClassValue, clsx } from 'clsx';
2import { twMerge } from 'tailwind-merge';
3
4/**
5 * Merges Tailwind CSS classes safely.
6 * Uses clsx for conditional classes and
7 * tailwind-merge to resolve conflicts.
8 *
9 * Example:
10 * cn('p-4 bg-red-500', isActive && 'bg-blue-500 p-6')
11 * When isActive: 'bg-blue-500 p-6' (p-6 overrides p-4, blue overrides red)
12 * When !isActive: 'p-4 bg-red-500'
13 */
14export function cn(...inputs: ClassValue[]) {
15 return twMerge(clsx(inputs));
16}
17
18// This file is auto-generated by V0/shadcn.
19// It's the standard utility used across all
20// shadcn/ui components for class merging.
21//
22// Dependencies: clsx, tailwind-merge
23// Install: npm install clsx tailwind-merge

Best practices to prevent this

  • Always verify globals.css has Tailwind directives before debugging individual class issues
  • Match Tailwind major versions between V0 export and your local project — v3 and v4 are not compatible
  • Use the cn() utility from lib/utils for all conditional or merged class names
  • Never construct Tailwind class names dynamically with template literals — use complete class strings for the scanner to find
  • Include all component directories in the tailwind.config.js content array (Tailwind v3)
  • Install the Tailwind CSS IntelliSense VSCode extension to catch class name errors during development
  • Test exported V0 code in a clean local environment to catch Tailwind configuration issues early
  • Keep PostCSS configured with tailwindcss and autoprefixer plugins in postcss.config.js

Still stuck?

Copy one of these prompts to get a personalized, step-by-step explanation.

ChatGPT Prompt

I exported V0 code into my Next.js project but none of the Tailwind CSS classes are applying. The components look like unstyled HTML. My local project uses Tailwind v4 but the V0 export seems to use v3. How do I fix the version mismatch and configuration?

Frequently asked questions

Why do Tailwind classes work in V0 but not after export?

V0's sandbox has Tailwind preconfigured. After export, your local project may have a different Tailwind version, missing directives in globals.css, or content paths that do not include V0's component directories.

What is the difference between Tailwind v3 and v4 configuration?

Tailwind v3 uses a JavaScript config file (tailwind.config.js) with a content array. Tailwind v4 uses CSS-based configuration with @import 'tailwindcss' and does not require a config file. The two formats are not compatible.

Why are my dynamic Tailwind classes not working?

Tailwind scans your source files for complete class names at build time. Dynamic classes like `bg-${color}-500` are not detected. Use complete class strings: 'bg-red-500' or 'bg-blue-500' in conditional expressions.

What does the cn() function do?

cn() combines clsx (for conditional classes) with tailwind-merge (for resolving conflicts). It ensures that when two conflicting classes like p-4 and p-6 are merged, the last one wins, producing clean output.

Do I need PostCSS for Tailwind in V0 projects?

Yes. PostCSS processes Tailwind directives into standard CSS. Your project needs a postcss.config.js with tailwindcss and autoprefixer plugins. V0 includes this by default, but it may be missing after manual export.

How do I check which Tailwind version my project uses?

Open package.json and look for the tailwindcss dependency version. V0 projects created before February 2026 use v3.4.17. Projects after that date use v4.2.0 or later.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your issue.

Book a free consultation

Need help with your Lovable project?

Our experts have built 600+ apps and can solve your issue fast. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.