src/skills/web-styling-tailwind/SKILL.md
Tailwind CSS v4 - utility-first CSS framework with CSS-first configuration
npx skillsauth add agents-inc/skills web-styling-tailwindInstall 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.
Quick Guide: Tailwind CSS v4 uses CSS-first configuration with
@import "tailwindcss"and@themedirective (NOTtailwind.config.js). Define design tokens as CSS variables in@theme, create custom utilities with@utility, custom variants with@custom-variant. Automatic content detection (nocontentarray). Use@tailwindcss/vitefor Vite,@tailwindcss/webpackfor Webpack. All colors use oklch. v4.1 adds text shadows, masks, and input-device variants. No Sass/Less/Stylus support.
Detailed Resources:
<critical_requirements>
All code must follow project conventions in CLAUDE.md (kebab-case, named exports, import ordering,
import type, named constants)
(You MUST use @import "tailwindcss" and @theme for configuration - NEVER use tailwind.config.js, @tailwind base, or module.exports)
(You MUST use @utility for custom utilities - NEVER use @layer utilities {} (v3 syntax))
(You MUST use oklch or CSS variable references for custom colors in @theme - NEVER use hex/rgb for theme tokens)
(You MUST use @tailwindcss/vite for Vite, @tailwindcss/webpack for Webpack, @tailwindcss/postcss for others - NEVER use tailwindcss directly as PostCSS plugin)
(You MUST specify border colors explicitly - v4 defaults to currentColor not gray-200)
</critical_requirements>
Auto-detection: Tailwind CSS, tailwindcss, @import "tailwindcss", @theme, @utility, @custom-variant, utility classes, bg-, text-, flex, grid, responsive design, dark:, hover:, focus:, @tailwindcss/vite, @tailwindcss/postcss, @tailwindcss/webpack, tailwind-merge, cn()
When to use:
@theme directivedark: variantKey patterns covered:
@import "tailwindcss" and @themesm:, md:, lg:)hover:, focus:, group-*:, peer-*:)@theme namespaces@utility and functional values@custom-variant@container, @sm:, @max-*:)rotate-x-*, perspective-*, transform-3d)@starting-style and @keyframescn() (clsx + tailwind-merge)When NOT to use:
Tailwind CSS v4 follows a utility-first, CSS-native approach: style directly in markup using composable utility classes, configure design tokens in CSS with @theme, and extend with @utility/@custom-variant directives. No JavaScript configuration files needed.
Core Principles:
@theme, not JavaScript@property, color-mix(), oklch colorsv4 vs v3 -- Key Differences:
| Aspect | v3 | v4 |
| ------------------ | ------------------------------------- | ----------------------- |
| Config | tailwind.config.js | @theme in CSS |
| Import | @tailwind base/components/utilities | @import "tailwindcss" |
| Custom utilities | @layer utilities {} | @utility name {} |
| Custom variants | addVariant() plugin | @custom-variant |
| Content detection | Manual content: [] | Automatic |
| Colors | sRGB hex/rgb | oklch (P3 gamut) |
| Border default | gray-200 | currentColor |
| Ring default | 3px blue-500 | 1px currentColor |
| Important modifier | !flex | flex! |
| Arbitrary vars | bg-[--var] | bg-(--var) |
| Container queries | Plugin required | Built-in |
| 3D transforms | Not available | Built-in |
| Text shadows | Not available | Built-in (v4.1) |
| Masks | Not available | Built-in (v4.1) |
Tailwind v4 replaces JavaScript config with CSS-first configuration. Use @import "tailwindcss" instead of @tailwind directives, and @theme instead of tailwind.config.js.
Vite projects (recommended): Use @tailwindcss/vite for optimal performance.
Webpack projects: Use @tailwindcss/webpack (added in v4.2).
Other bundlers: Use @tailwindcss/postcss as PostCSS plugin.
CLI: Use @tailwindcss/cli for standalone builds.
@import "tailwindcss" replaces the three @tailwind directives@theme defines design tokens that generate utility classes AND CSS variables@source adds paths not caught by automatic content detection@source not excludes paths from scanning (v4.1)@source inline("...") safelists specific utilities without source files (v4.1)@reference imports theme/utilities for scoped styles (Vue SFC, CSS Modules) without duplicating outputcontent array needed -- Tailwind auto-detects template files respecting .gitignoreFor implementation examples, see examples/core.md.
Tailwind v4 uses mobile-first responsive design with breakpoint variants. Default breakpoints: sm (40rem), md (48rem), lg (64rem), xl (80rem), 2xl (96rem).
@theme with --breakpoint-* namespacemd:max-lg:hidden (hide between md and lg)max-* variants for max-width queries: max-md:hiddenFor implementation examples, see examples/core.md.
Tailwind v4 supports three dark mode strategies: media query (default), class-based toggle, and data-attribute toggle. Override the dark variant with @custom-variant.
prefers-color-scheme: dark -- zero config.dark class to <html> -- use @custom-variant darkdata-theme="dark" -- use @custom-variant darkdark variant with @custom-variant(&:where(.dark, .dark *)) selector for class strategy@theme can reference CSS variables set by theme classFor implementation examples, see examples/core.md.
Tailwind v4 provides comprehensive state variants for interactive styling. The not-* variant is new in v4.
hover:, focus:, active:, visited:, first:, last:, odd:, even:, disabled:, required:, invalid:group-hover:, group-focus:, peer-checked:, peer-invalid:data-[state=active]:, data-current:not-hover:, not-focus:, inert:, starting: (for @starting-style)pointer-fine:, pointer-coarse:, user-valid:, user-invalid:, noscript:, details-content:, inverted-colors:@sm:, @md:, @lg:, @max-sm:hover: only applies on devices with hover capability (no more mobile ghost hovers)not-* variant styles when condition is NOT metdark:hover:bg-gray-700For implementation examples, see examples/core.md.
The @theme directive defines design tokens that generate both utility classes and CSS variables. Each namespace maps to specific utility types.
| Namespace | Generates | Example |
| ------------------ | ------------------------ | -------------------------------- |
| --color-* | Color utilities | bg-brand-500, text-brand-500 |
| --font-* | Font family | font-display |
| --font-weight-* | Font weight | font-bold |
| --text-* | Font size | text-display |
| --tracking-* | Letter spacing | tracking-wide |
| --leading-* | Line height | leading-tight |
| --spacing-* | Spacing and sizing | px-compact, max-h-16 |
| --breakpoint-* | Responsive variants | 3xl:flex |
| --container-* | Container query variants | @sm:*, max-w-md |
| --radius-* | Border radius | rounded-card |
| --shadow-* | Box shadows | shadow-card |
| --inset-shadow-* | Inset box shadows | inset-shadow-xs |
| --drop-shadow-* | Drop shadow filters | drop-shadow-md |
| --ease-* | Timing functions | ease-fluid |
| --animate-* | Animations | animate-fade-in |
| --blur-* | Blur filters | blur-card |
| --perspective-* | 3D perspective | perspective-card |
| --aspect-* | Aspect ratios | aspect-cinema |
--color-*: initial resets all default colors before defining custom ones--*: initial resets the entire default theme@theme inline prevents CSS variable resolution issues when referencing other variables@theme static generates CSS variables even when utilities are unused@keyframes can be defined inside @theme for animation tokensFor implementation examples, see examples/core.md.
The @utility directive replaces v3's @layer utilities {}. Supports static utilities, functional utilities with --value(), and modifiers with --modifier().
@utility content-auto { content-visibility: auto; })--value() (@utility tab-* { tab-size: --value(integer); })--modifier() for secondary values--value(--namespace-*) matches theme variables--value(integer) matches bare integer values--value([length]) matches arbitrary values in brackets--value() declarations cascade (last match wins)For implementation examples, see examples/advanced.md.
The @custom-variant directive replaces v3's addVariant() plugin API. Define conditional styling rules in CSS. The @variant directive applies existing variants inline within CSS rules.
@custom-variant name (selector);@custom-variant name { /* rules with @slot */ }@variant dark { /* styles */ } -- apply a variant inside custom CSSFor implementation examples, see examples/advanced.md.
Container queries are built into v4 core (no plugin needed). Style elements based on container size, not viewport.
@container makes an element a query container@sm:, @md:, @lg: apply at container breakpoints (not viewport)@max-sm:, @max-md: for max-width container queries@min-md:@max-xl: for range queries@container/name and @sm/name:For implementation examples, see examples/advanced.md.
Tailwind v4 adds first-class 3D transform utilities and leverages modern CSS features.
rotate-x-*, rotate-y-*, rotate-z-* for 3D rotationtranslate-z-* for depth translationscale-z-* for depth scalingperspective-* and perspective-origin-* for 3D perspectivetransform-3d to enable 3D transform contextbackface-hidden / backface-visible for card-flip effects@starting-style via starting: variant for enter/exit animationsfield-sizing-content for auto-resizing textareascolor-scheme-dark for native dark mode scrollbarsinset-shadow-* and inset-ring-* for layered box shadowstext-shadow-* for text shadows with color/opacity support (v4.1)mask-* for gradient and image masking (v4.1)wrap-break-word / wrap-anywhere for overflow-wrap control (v4.1)--alpha() function for adjusting color opacity in custom CSSFor implementation examples, see examples/advanced.md.
Use cn() (clsx + tailwind-merge) to handle class composition and conflict resolution. Compose utility classes programmatically when components need variants or overridable styles.
cn() combines clsx (conditional classes) with twMerge (conflict resolution)className should always be last in cn() to allow consumer overridescn() for simple compositioncn() over @apply for component extraction (keeps utilities visible in code)For implementation examples, see examples/advanced.md.
</patterns><decision_framework>
Need component variants (size, intent, state)?
|-- YES --> Variant objects + cn() + Tailwind classes
|-- NO --> Just utility classes in markup
Need custom utility not in Tailwind?
|-- YES --> Is it a single fixed style?
| |-- YES --> @utility name { declarations }
| |-- NO --> @utility name-* { --value() }
|-- NO --> Use built-in utilities
Need conditional styling based on parent/sibling state?
|-- YES --> Is parent state?
| |-- YES --> group/group-* pattern
| |-- NO --> peer/peer-* pattern
|-- NO --> Direct state variants (hover:, focus:)
Need responsive behavior based on...?
|-- Viewport size --> sm:/md:/lg: breakpoint variants
|-- Container size --> @container + @sm:/@md: variants
|-- Neither --> Static styling
Is dark mode automatic (system preference only)?
|-- YES --> No config needed (default prefers-color-scheme)
|-- NO --> Need manual toggle?
|-- YES --> Using class on <html>?
| |-- YES --> @custom-variant dark (&:where(.dark, .dark *))
| |-- NO --> @custom-variant dark (&:where([data-theme=dark], [data-theme=dark] *))
|-- NO --> Default media query
Need to add a few custom tokens?
|-- YES --> Add to @theme alongside defaults
Need to replace an entire namespace?
|-- YES --> --namespace-*: initial; then define custom tokens
Need fully custom theme (no defaults)?
|-- YES --> --*: initial; then define everything
Need to share theme across projects?
|-- YES --> Create shared theme.css, import with @import
Is the project actively maintained?
|-- YES --> Does it use tailwind.config.js plugins?
| |-- YES --> Can plugins be replaced with @utility/@custom-variant?
| | |-- YES --> Migrate to v4
| | |-- NO --> Keep v3 or use @config/@plugin compatibility
| |-- NO --> Migrate to v4 (run npx @tailwindcss/upgrade)
|-- NO --> Stay on v3.4 (stable, still supported)
</decision_framework>
Bundler Setup:
@tailwindcss/vite for Vite-based projects (fastest)@tailwindcss/webpack for Webpack projects (v4.2+)@tailwindcss/postcss for other bundlers@tailwindcss/cli for standalone buildsautoprefixer and postcss-import are NOT needed with v4Component Integration:
cn() for class composition and conflict resolutionclassName prop for consumer overridestailwind-merge to resolve conflicting utility classesWhat Tailwind Does NOT Replace:
@keyframes (use @theme for tokens, custom CSS for complex sequences)bg-(--my-var) arbitrary syntax)<red_flags>
High Priority Issues:
tailwind.config.js without @config directive (v4 does NOT auto-detect JS config)@tailwind base; @tailwind components; @tailwind utilities; (v3 syntax, use @import "tailwindcss")@layer utilities {} for custom utilities (use @utility directive)tailwindcss directly as PostCSS plugin (use @tailwindcss/postcss)!flex important syntax (v4 uses flex! -- trailing not leading)bg-[--my-var] for CSS variables (v4 uses bg-(--my-var) with parentheses)@theme (use oklch for P3 gamut support)border defaults to gray-200 (v4 defaults to currentColor)ring defaults to 3px (v4 defaults to 1px)Medium Priority Issues:
@apply for component extraction (use cn() with tailwind-merge instead -- keeps utilities visible)@source for node_modules UI libraries (automatic detection skips node_modules)autoprefixer or postcss-import (not needed with v4)transform-none to reset transforms (v4 uses individual properties, use scale-none / rotate-0)Common Mistakes:
@custom-variant dark when using class-based dark mode togglecontent: ['./src/**/*.tsx'] (v4 auto-detects, no content array)npx @tailwindcss/upgrade for automated migrationGotchas and Edge Cases:
hover: only triggers on devices with hover capability (no phantom hover on touch devices)space-y-* / divide-* changed selectors: v3 used :not([hidden]) ~ :not([hidden]), v4 uses :not(:last-child) -- prefer gap-* with flex/gridgrid-cols-[max-content_auto] (not commas)shadow-sm in v3 = shadow-xs in v4, shadow in v3 = shadow-sm in v4 (whole scale shifted)rounded-sm in v3 = rounded-xs in v4, rounded in v3 = rounded-sm in v4outline-none in v3 = outline-hidden in v4 (accessibility improvement)ring in v3 (3px) = ring-3 in v4 (default is now 1px)</red_flags>
<critical_reminders>
All code must follow project conventions in CLAUDE.md (kebab-case, named exports, import ordering,
import type, named constants)
(You MUST use @import "tailwindcss" and @theme for configuration - NEVER use tailwind.config.js, @tailwind base, or module.exports)
(You MUST use @utility for custom utilities - NEVER use @layer utilities {} (v3 syntax))
(You MUST use oklch or CSS variable references for custom colors in @theme - NEVER use hex/rgb for theme tokens)
(You MUST use @tailwindcss/vite for Vite, @tailwindcss/webpack for Webpack, @tailwindcss/postcss for others - NEVER use tailwindcss directly as PostCSS plugin)
(You MUST specify border colors explicitly - v4 defaults to currentColor not gray-200)
Failure to follow these rules will produce v3 code that does not work with Tailwind CSS v4.
</critical_reminders>
development
Material Design component library for Vue 3
development
VitePress 1.x — Vue-powered static site generator for documentation sites, built on Vite
tools
Docusaurus 3.x documentation framework — site configuration, docs/blog plugins, sidebars, versioning, MDX, swizzling, and deployment
development
TanStack Form patterns - useForm, form.Field, validators, arrays, linked fields, createFormHook, type safety