Ad
Adam Wathan & Tailwind Community@adamwathanCore Maintainer VerifiedTailwind Labs

Specification Author & Maintainer • Verified via AgentRules Industrial Quality Gate

frontendhigh PriorityID: tailwind-v4

Tailwind CSS v4 Modern Theme & Pure CSS Standard

Guardrails for Tailwind CSS v4: use @import 'tailwindcss', @theme directive in CSS, native cascade layers, and pure CSS variables instead of tailwind.config.js.

Prohibited Anti-Pattern: AI attempts to generate a legacy tailwind.config.js, uses deprecated @apply syntax, or confuses v3 arbitrary values.

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tailwind CSS v4 Modern Theme & Pure CSS Standard - Guardrails for Tailwind CSS v4: use @import 'tailwindcss', @theme directive in CSS, native cascade layers, and pure CSS variables instead of tailwind.config.js.
globs: **/*.css, src/**/*.{tsx,html}
alwaysApply: false
author: "Adam Wathan & Tailwind Community (@adamwathan)"
contributor_url: "https://github.com/adamwathan"
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/tailwind-v4"
---

# Tailwind CSS v4 Modern Theme & Pure CSS Standard

> **Severity**: HIGH | **Category**: frontend
> **Anti-Pattern Warning**: AI attempts to generate a legacy tailwind.config.js, uses deprecated @apply syntax, or confuses v3 arbitrary values.

## System Constraints
You are a modern frontend styling expert for Tailwind CSS v4. Do NOT generate tailwind.config.js or tailwind.config.ts. In Tailwind v4, configuration belongs directly in CSS using the @theme directive. Never generate deprecated utility classes.

## Strict Guidelines
- In Tailwind v4, use @import 'tailwindcss'; as the single entrypoint in CSS.
- Configure custom colors, fonts, and breakpoints directly inside the @theme block in CSS, not in a JS config file.
- Avoid over-relying on @apply; favor semantic utility classes in markup or native CSS variables.
- Ensure color palette values map to semantic CSS custom properties for effortless dark mode switching.

## Bad vs Good Implementations
### Tailwind v4 CSS-First Configuration

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Tailwind v4 replaces @tailwind directives with a single @import 'tailwindcss' and moves config into @theme blocks.
```css
/* DEPRECATED: Tailwind v3 Directives */
@tailwind base;
@tailwind components;
@tailwind utilities;

/* And hallucinating a separate tailwind.config.js file with module.exports */
```

#### Production Standard (Correct)
> **Standard**: Uses modern Tailwind CSS v4 syntax with pure CSS variables and the native @theme declaration.
```css
/* Modern Tailwind CSS v4 */
@import "tailwindcss";

@theme {
  --color-brand-primary: #0284c7;
  --color-brand-surface: #f8fafc;
  --font-display: "Inter", system-ui, sans-serif;
  --radius-card: 0.5rem;
}

:root {
  --background: var(--color-brand-surface);
  --foreground: #0f172a;
}
```

Recommended MCP Servers (mcp-serverlist.com)

Equip agent with system tools to verify code for this stack.

Recommended Agent Skills (askills.dev)

Ready-to-use executable skill functions tailored to this stack.

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Tailwind CSS v4 Modern Theme & Pure CSS Standard

Tailwind CSS v4 is a ground-up rebuild centered around native CSS cascading variables, CSS lightning engine compilation, and zero-configuration setups. The traditional `tailwind.config.js` or `tailwind.config.ts` configuration file is obsolete; all design tokens, theme scales, and custom plugins are defined directly in CSS via `@theme` directives and modern `@import "tailwindcss";`.

Framework Paradigm Shift & Drift MechanicsLLMs have memorized the v2 and v3 configuration schema (`module.exports = { theme: { extend: {} } }`). When asked to customize colors or fonts in a Tailwind v4 project, AI models frequently generate a duplicate `tailwind.config.js` file that is ignored by v4 Vite and PostCSS plugins, leaving developers confused as to why styles are not applying.
Failure Modes & Production Blast Radius

Hazard Analysis: What Breaks Without This Rule

The following failure modes have been cataloged from hundreds of hours of production code reviews where AI assistants produced non-compliant implementations:

Failure ModeAI Symptom (The Anti-Pattern)SeverityProduction Impact & Remedy
Ghost tailwind.config.js GenerationAI outputs a JavaScript configuration file instead of CSS @theme directivesHigh
Configurations are ignored by Tailwind v4's modern CSS compiler, breaking custom design systems.
Declare custom design tokens directly in `src/app/globals.css` using the `@theme { ... }` block.
Deprecated PostCSS / @apply SyntaxAI writes `@tailwind base; @tailwind components; @tailwind utilities;`Medium
Fails compilation in Tailwind v4 and creates build errors with modern bundlers like Turbopack.
Replace legacy triple-directive with single `@import "tailwindcss";` at stylesheet root.
Architectural Directives in Detail

Step-by-Step Production Directives

Each rule constraint below is injected into the AI agent's system prompt to establish deterministic boundaries:

1

In Tailwind v4, use @import 'tailwindcss'

In Tailwind v4, use @import 'tailwindcss'; as the single entrypoint in CSS.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
2

Configure custom colors, fonts, and breakpoints directly inside the @theme block in CSS, not in a JS config file.

Configure custom colors, fonts, and breakpoints directly inside the @theme block in CSS, not in a JS config file.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
3

Avoid over-relying on @apply

Avoid over-relying on @apply; favor semantic utility classes in markup or native CSS variables.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
4

Ensure color palette values map to semantic CSS custom properties for effortless dark mode switching.

Ensure color palette values map to semantic CSS custom properties for effortless dark mode switching.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
Technical Questions & Answers

Frequently Asked Technical Questions

Common questions developers face when configuring AI coding assistants for this stack:

Q:Where do I configure custom colors in Tailwind CSS v4?

In Tailwind v4, configure tokens directly inside your primary CSS file using `@theme`: `@theme { --color-brand-primary: #0284c7; }`. This automatically generates `bg-brand-primary` and `text-brand-primary` utilities.

Q:Why does Tailwind v4 not use tailwind.config.js?

Tailwind v4 is powered by Oxide, a high-performance Rust engine that parses CSS natively. Removing the JavaScript configuration file allows instant hot-reloading and seamless interoperability with CSS custom properties.

Open Specification · CC BY 4.0·Free for Personal, Team & Commercial In-Repo Use

Citation & Open Source Attribution Guidelines

This specification is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0). You are completely free to adapt and share this rule in your workspace. If citing, including in public AI benchmark datasets, or redistributing, attribution to AgentRules.org is required.

Related FRONTEND Rules

View all rules →
frontend
119

SolidStart 1.0 Server Functions & Async Boundaries Production Standard

SolidStart 1.0 relies on the Vinxi bundler to split `server$` closures into independent HTTP POST RPC endpoints. Direct lexical closure over client signals within `server$` scopes or failure to demarcate async boundaries with `<Suspense>` causes silent serialization failures, client-bundle secret leaks, and SSR hydration mismatches. Enforcing strict parameter passing, runtime input validation, and Solid async primitives maintains security and fine-grained reactivity across network boundaries.

frontend
119

Astro 5 Actions & Content Layer Production Standard

Enforces strict type safety and architectural correctness for Astro 5 Server Actions and the zero-waterfall Content Layer API. Prevents runtime contract mismatches, hydration mismatches, and unhandled mutation exceptions across dynamic and prerendered boundaries. Failure to follow these patterns leads to silent data fetching waterfalls, build-time cache corruptions, and unhandled server action exceptions.

frontend
51

Nuxt 4 Nitro Server Engine & Shared Directory Production Standard

Nuxt 4 enforces strict boundary segregation between client UI in the app/ directory, backend endpoints in server/, and universal contracts in shared/. Violating cross-boundary isolation or maintaining module-scoped state in Nitro server handlers causes catastrophic cross-request data corruption and hydration mismatches under concurrent production traffic. Architects must enforce request-isolated H3 event contexts, universal serialization schemas, and strict path-alias boundaries.

1 Rule in Stack

Tailwind