Expert guidance for leveraging Tailwind CSS V4's new Oxide engine, CSS-first configuration, and modern styling paradigms...
Tailwind V4 represents a philosophical shift from JavaScript-centric utility frameworks to CSS-native, declarative styling. This skill installs that mental model:
@theme {} replaces tailwind.config.js@property, color-mix(), CSS nestingThe correct mental model for V4: "CSS is the source of truth. JavaScript configuration is outdated."
What Changed:
v3: JavaScript β JavaScript Parser β CSS Output
v4: CSS @theme β Rust/Oxide Engine β Optimized CSS Output
Why It Matters:
Mental Model: Think of the Oxide engine as a compiler, not a preprocessor. It compiles CSS declarations into optimized output.
The Core Shift:
| Aspect | v3 | v4 |
|---|---|---|
| Config Format | JavaScript Object | CSS @theme {} Block |
| Location | tailwind.config.js |
styles.css |
| Execution | Node.js at build time | Oxide engine |
| Debugging | Console logs, file inspection | CSS DevTools |
| Scope | Global import | CSS cascade-aware |
Why This Matters: CSS-first configuration is more maintainable, debuggable, and aligned with how browsers actually work. You're no longer fighting a layer of abstraction.
Tailwind V4 requires modern browser capabilities:
@property)color-mix())This is intentional. V4 assumes modern CSS and optimizes around it. Legacy support requires v3.4.x.
Trigger: User wants to upgrade existing Tailwind project from v3 to v4
Steps:
Audit Phase
tailwind.config.js overridesInstallation Phase
npm install -D tailwindcss@latest
npm install -D @tailwindcss/vite # (or @tailwindcss/postcss or @tailwindcss/cli)
Configuration Migration
theme: {} β @theme { --var: value; }extend: {} β Additional --var in @theme@tailwind base/components/utilities β @import "tailwindcss"Utility Refactoring
.shadow β .shadow-sm.rounded β .rounded-sm.outline-none β .outline-hidden.bg-opacity-* β .bg-black/* (slash syntax)Validation
Decision Tree:
Is this a new project?
ββ YES β Use V4 directly with @theme config
ββ NO β Execute migration workflow above
ββ Does v3 use custom config extensively?
β ββ YES β Allocate migration time, go step-by-step
β ββ NO β Quick migration, 30 mins
ββ Are you on legacy browsers?
ββ YES β Stay on v3.4
ββ NO β Proceed with v4
Trigger: User wants to build reusable component library with Tailwind V4
Steps:
Define Component Scope
Create Base Theme
@import "tailwindcss";
@theme {
/* Color system */
--color-primary-*: oklch(...);
--color-neutral-*: oklch(...);
/* Spacing scale */
--spacing-xs: 0.25rem;
--spacing-sm: 0.5rem;
--spacing-md: 1rem;
/* Typography */
--font-display: "Custom", sans-serif;
--font-body: "System", sans-serif;
}
Build Component Classes
@layer components {
.btn-primary {
@apply px-4 py-2 rounded-sm bg-primary text-white
font-semibold transition-all hover:opacity-90;
}
.card {
@apply p-6 rounded-lg bg-white shadow-md border border-gray-200;
}
}
Establish Modifier Conventions
.btn-sm, .btn-lg.btn-disabled, .btn-loading.btn-primary, .btn-secondaryDocument & Export
Output: Production-ready component library CSS file
Trigger: User needs to optimize Tailwind V4 performance
Steps:
Baseline Measurement
Plugin Selection
@tailwindcss/vite (fastest option)Configuration Tuning
// vite.config.ts
import tailwindcss from "@tailwindcss/vite";
export default defineConfig({
plugins: [react(), tailwindcss()]
});
CSS Variable Optimization
@theme block duplicationValidation
Expected Outcomes:
What build tool do you use?
ββ Vite (React, Vue, Svelte)
β ββ Use @tailwindcss/vite (fastest, recommended)
ββ Webpack (NextJS, CRA)
β ββ Use @tailwindcss/postcss
ββ Standalone/No bundler
β ββ Use @tailwindcss/cli
ββ PostCSS pipeline
ββ Use @tailwindcss/postcss
How complex is your theme?
ββ Simple (5-10 color overrides)
β ββ Use inline @theme block in styles.css
ββ Moderate (custom colors, spacing, fonts)
β ββ Use single @theme block with organization
ββ Complex (multi-theme, extensive customization)
β ββ Split into @layer base blocks with [data-theme] selectors
ββ Enterprise (multiple brands)
ββ Use CSS variable strategy with fallbacks
When should I use @layer components?
ββ Recurring utility combinations
β ββ YES β Extract to .btn-primary, .card, etc.
ββ One-off layouts
β ββ NO β Use utilities directly in HTML
ββ Design system compliance needed
β ββ YES β Extract as component class
ββ User will customize per instance
ββ NO β Leave as utility composition
tailwind.config.js to Still WorkProblem: File is ignored in v4.
Solution: Use @theme {} in CSS instead.
Prevention: Delete tailwind.config.js early in migration.
Problem: v3 used currentColor (inherits text), v4 uses #e5e7eb.
Solution: Use .border-current if you need inherited color.
Prevention: Test all border utilities during migration.
Problem: Existing .ring classes now have thinner outlines.
Solution: Use .ring-3 for old 3px behavior, .ring-1 for new default.
Prevention: Find/replace .ring β .ring-1 during migration.
-- PrefixProblem: @theme { color-primary: value; } is ignored.
Solution: Use @theme { --color-primary: value; }.
Prevention: Always use -- in @theme blocks.
Problem: .bg-opacity-50 no longer exists.
Solution: Use CSS color modifiers: .bg-black/50.
Prevention: Search codebase for opacity utilities and replace during migration.
All detailed references are stored in references/:
@theme setup patternsβ Use this skill when:
β Don't use this skill when:
When activated by user query:
This skill enables Claude to:
Skill Version: 1.0.0
Last Updated: 2025-01-01
Status: Production Ready