My-opencode-config tailwind-v4-configuration
Configure Tailwind CSS v4 with CSS-first approach. Use when installing, migrating from v3, setting up build tools (Vite/PostCSS/CLI), customizing themes with @theme, or configuring plugins.
install
source · Clone the upstream repo
git clone https://github.com/flpbalada/my-opencode-config
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/flpbalada/my-opencode-config "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/tailwind-v4-configuration" ~/.claude/skills/flpbalada-my-opencode-config-tailwind-v4-configuration && rm -rf "$T"
manifest:
skills/tailwind-v4-configuration/SKILL.mdsource content
Tailwind CSS v4 Configuration
A complete guide to configuring Tailwind CSS v4 with its new CSS-first approach, unified toolchain, and modern feature set.
When to Use This Skill
- Installing Tailwind v4 for the first time in a new project
- Migrating from Tailwind v3 to v4 (breaking changes and setup differences)
- Setting up build tools: Vite, PostCSS, or standalone CLI
- Customizing themes using the
directive@theme - Configuring content paths and template detection
- Adding plugins or creating custom utilities
- Configuring dark mode, prefixes, or other global options
- Troubleshooting v4 configuration issues
Key v4 Changes Overview
| Aspect | v3 | v4 |
|---|---|---|
| Configuration | (JavaScript) | block in CSS |
| Import | Three directives | Single |
| Content paths | Explicit array | Automatic detection (respects ) |
| Build pipeline | Requires PostCSS + plugins | Integrated Lightning CSS (all-in-one) |
| Performance | Fast | 10x faster (Oxide engine) |
| Colors | hex, rgb, hsl | Native + modern color spaces |
| Variants | removed outline | + proper |
| Shadows | (smallest) | (smallest), (default) |
| Border radius | (smallest) | (smallest), (default) |
Core Concepts
CSS-First Configuration
All configuration now lives in your CSS file using the
@theme directive:
@import "tailwindcss"; @theme { --color-brand-primary: oklch(0.65 0.24 354.31); --font-display: "Satoshi", "sans-serif"; --breakpoint-3xl: 1920px; }
Automatic Content Detection
v4 automatically discovers templates - no configuration needed for most projects.
Key Utility Changes
(v3) →shadow-sm
(v4)shadow-xs
(v3) →rounded-sm
(v4)rounded-xs
(v3) →bg-gradient-to-r
(v4)bg-linear-to-r
Progressive Disclosure
This skill provides detailed examples through context files. Load them when needed:
| Context File | When to Load |
|---|---|
| Setting up installation, CSS config, custom utils |
| Migrating from v3 to v4 |
| Setting up Next.js, React, Vue, SvelteKit |
| Multi-stylesheets, theming, animations |
Best Practices
✅ DO
- Use
with a single import@import "tailwindcss" - Define theme tokens in
block@theme - Leverage automatic content detection
- Use CSS variables with
for dynamic theming@theme - Use
for custom utilities (not@utility
for components)@apply - Use
for reusable variant logic@custom-variant - Test the automated upgrade tool before manual migration
❌ DON'T
- Create a
file (use CSStailwind.config.js
instead)@theme - Use
separately@tailwind base/components/utilities - Configure
paths unless you have a specific needcontent - Forget to update breaking utility changes (shadow, blur, radius)
- Use opacity utilities like
(usebg-opacity-50
instead)/50 - Ignore browser compatibility (v4 targets modern browsers)
- Try to load legacy
orautoprefixerpostcss-import
Browser Compatibility
Tailwind CSS v4 targets modern browsers:
- Chrome/Edge: 111+
- Firefox: 128+
- Safari: 16.4+
Quick Decision Guide
Need to install Tailwind v4? ├─ New project? → Use Vite plugin (recommended) ├─ Existing project? → Use PostCSS plugin └─ Static site? → Use CLI Migrating from v3? └─ Run: npx @tailwindcss/upgrade Need custom utilities? └─ Use @utility directive in CSS Need framework setup? └─ See context/framework-examples.md