skills/tailwindcss-v4/SKILL.md
Tailwind CSS v4 patterns: CSS-first config, @theme/@utility/@variant directives, migration from v3. Use when working with Tailwind v4 projects.
npx skillsauth add HadiCherkaoui/opencode-config tailwindcss-v4Install this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
CSS-first configuration, new directives, migration from v3.
@import "tailwindcss";
NOT the v3 way:
/* ❌ These cause errors in v4 */
@tailwind base;
@tailwind components;
@tailwind utilities;
| Directive | Purpose |
|-----------|---------|
| @theme | Define design tokens (colors, spacing, fonts) |
| @utility | Create custom utility classes |
| @variant | Define custom variants (hover, focus, etc.) |
| @source | Control class detection and safelisting |
| @reference | Import for @apply without emitting CSS |
@import "tailwindcss";
@theme {
--color-primary: #3b82f6;
--color-secondary: #64748b;
--font-display: "Inter", sans-serif;
--spacing-18: 4.5rem;
}
NOT tailwind.config.js:
// ❌ v3 pattern - don't use in v4
module.exports = {
theme: {
extend: {
colors: { primary: '#3b82f6' }
}
}
}
@utility content-auto {
content-visibility: auto;
}
/* Functional utility must end in -* */
@utility tab-* {
--tab-size: --value(--spacing-*, [integer]);
tab-size: var(--tab-size);
}
Use @custom-variant to define new variants (not @variant).
@custom-variant hocus (&:hover, &:focus);
/* Dark mode with class strategy */
@custom-variant dark (&:is(.dark *));
/* Body block with @slot */
@custom-variant hocus {
&:hover, &:focus { @slot; }
}
@theme {
--color-primary: #3b82f6;
/* Clear namespace */
--color-*: initial;
}
default: Merge with default themeinline: Emit variables to outputstatic: Use values but don't emit varsreference: Use values but don't emit CSS@theme inline {
--font-sans: "SF Pro Text", system-ui;
}
<!-- v4 preferred - supports interpolation color space -->
<div class="bg-linear-to-r/oklch from-blue-500 to-purple-500"></div>
<!-- Also: bg-linear-to-b, bg-radial, bg-conic -->
@min-[400px]: / @max-[600px]: (Container queries)starting: (@starting-style)details-content: (::details-content)inverted-colors:, noscript:, print:/* Inline safelist */
@source inline("bg-red-500 text-white hidden");
/* From external source */
@source "../content/**/*.md";
| v3 | v4 |
|----|-----|
| @tailwind base/components/utilities | @import "tailwindcss" |
| tailwind.config.js theme.extend | @theme { --color-* } |
| PostCSS tailwindcss plugin | @tailwindcss/postcss |
| @apply with config values | @reference import first |
// postcss.config.js
export default {
plugins: {
'@tailwindcss/postcss': {} // NOT 'tailwindcss'
}
}
// vite.config.ts
import tailwindcss from '@tailwindcss/vite'
export default {
plugins: [tailwindcss()]
}
Sources: Tailwind v4 Docs, GitHub
development
Use when you have a spec or requirements for a multi-step task, before touching code
data-ai
Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always
tools
Use when starting feature work that needs isolation from current workspace or before executing implementation plans - creates isolated git worktrees with smart directory selection and safety verification
development
Use when implementing any feature or bugfix, before writing implementation code