tailwind-v4-shadcn
Set up Tailwind v4 with shadcn/ui using @theme inline pattern and CSS variable architecture. Four-step pattern: CSS variables, Tailwind mapping, base styles, automatic dark mode. Prevents 8 documented errors. Use when initializing React projects with Tailwind v4, or fixing colors not working, tw-animate-css errors, @theme inline dark mode conflicts, @apply breaking, v3 migration issues.
What this skill does
# Tailwind v4 + shadcn/ui Production Stack **Production-tested**: WordPress Auditor (https://wordpress-auditor.webfonts.workers.dev) **Last Updated**: 2026-01-20 **Versions**: [email protected], @tailwindcss/[email protected] **Status**: Production Ready ✅ --- ## Quick Start (Follow This Exact Order) ```bash # 1. Install dependencies pnpm add tailwindcss @tailwindcss/vite pnpm add -D @types/node tw-animate-css pnpm dlx shadcn@latest init # 2. Delete v3 config if exists rm tailwind.config.ts # v4 doesn't use this file ``` **vite.config.ts**: ```typescript import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' import tailwindcss from '@tailwindcss/vite' import path from 'path' export default defineConfig({ plugins: [react(), tailwindcss()], resolve: { alias: { '@': path.resolve(__dirname, './src') } } }) ``` **components.json** (CRITICAL): ```json { "tailwind": { "config": "", // ← Empty for v4 "css": "src/index.css", "baseColor": "slate", "cssVariables": true } } ``` --- ## The Four-Step Architecture (MANDATORY) Skipping steps will break your theme. Follow exactly: ### Step 1: Define CSS Variables at Root ```css /* src/index.css */ @import "tailwindcss"; @import "tw-animate-css"; /* Required for shadcn/ui animations */ :root { --background: hsl(0 0% 100%); /* ← hsl() wrapper required */ --foreground: hsl(222.2 84% 4.9%); --primary: hsl(221.2 83.2% 53.3%); /* ... all light mode colors */ } .dark { --background: hsl(222.2 84% 4.9%); --foreground: hsl(210 40% 98%); --primary: hsl(217.2 91.2% 59.8%); /* ... all dark mode colors */ } ``` **Critical**: Define at root level (NOT inside `@layer base`). Use `hsl()` wrapper. ### Step 2: Map Variables to Tailwind Utilities ```css @theme inline { --color-background: var(--background); --color-foreground: var(--foreground); --color-primary: var(--primary); /* ... map ALL CSS variables */ } ``` **Why**: Generates utility classes (`bg-background`, `text-primary`). Without this, utilities won't exist. ### Step 3: Apply Base Styles ```css @layer base { body { background-color: var(--background); /* NO hsl() wrapper here */ color: var(--foreground); } } ``` **Critical**: Reference variables directly. Never double-wrap: `hsl(var(--background))`. ### Step 4: Result - Automatic Dark Mode ```tsx <div className="bg-background text-foreground"> {/* No dark: variants needed - theme switches automatically */} </div> ``` --- ## Dark Mode Setup **1. Create ThemeProvider** (see `templates/theme-provider.tsx`) **2. Wrap App**: ```typescript // src/main.tsx import { ThemeProvider } from '@/components/theme-provider' ReactDOM.createRoot(document.getElementById('root')!).render( <ThemeProvider defaultTheme="dark" storageKey="vite-ui-theme"> <App /> </ThemeProvider> ) ``` **3. Add Theme Toggle**: ```bash pnpm dlx shadcn@latest add dropdown-menu ``` See `reference/dark-mode.md` for ModeToggle component. --- ## Critical Rules ### ✅ Always Do: 1. Wrap colors with `hsl()` in `:root`/`.dark`: `--bg: hsl(0 0% 100%);` 2. Use `@theme inline` to map all CSS variables 3. Set `"tailwind.config": ""` in components.json 4. Delete `tailwind.config.ts` if exists 5. Use `@tailwindcss/vite` plugin (NOT PostCSS) ### ❌ Never Do: 1. Put `:root`/`.dark` inside `@layer base` (causes cascade issues) 2. Use `.dark { @theme { } }` pattern (v4 doesn't support nested @theme) 3. Double-wrap colors: `hsl(var(--background))` 4. Use `tailwind.config.ts` for theme (v4 ignores it) 5. Use `@apply` directive (deprecated in v4, see error #7) 6. Use `dark:` variants for semantic colors (auto-handled) 7. Use `@apply` with `@layer base` or `@layer components` classes (v4 breaking change - use `@utility` instead) | [Source](https://github.com/tailwindlabs/tailwindcss/discussions/17082) 8. Wrap ANY styles in `@layer base` without understanding CSS layer ordering (see error #8) | [Source](https://github.com/tailwindlabs/tailwindcss/discussions/16002) --- ## Common Errors & Solutions This skill prevents **8 documented errors**. ### 1. ❌ tw-animate-css Import Error **Error**: "Cannot find module 'tailwindcss-animate'" **Cause**: shadcn/ui deprecated `tailwindcss-animate` for v4. **Solution**: ```bash # ✅ DO pnpm add -D tw-animate-css # Add to src/index.css: @import "tailwindcss"; @import "tw-animate-css"; # ❌ DON'T npm install tailwindcss-animate # v3 only ``` --- ### 2. ❌ Colors Not Working **Error**: `bg-primary` doesn't apply styles **Cause**: Missing `@theme inline` mapping **Solution**: ```css @theme inline { --color-background: var(--background); --color-foreground: var(--foreground); --color-primary: var(--primary); /* ... map ALL CSS variables */ } ``` --- ### 3. ❌ Dark Mode Not Switching **Error**: Theme stays light/dark **Cause**: Missing ThemeProvider **Solution**: 1. Create ThemeProvider (see `templates/theme-provider.tsx`) 2. Wrap app in `main.tsx` 3. Verify `.dark` class toggles on `<html>` element --- ### 4. ❌ Duplicate @layer base **Error**: "Duplicate @layer base" in console **Cause**: shadcn init adds `@layer base` - don't add another **Solution**: ```css /* ✅ Correct - single @layer base */ @import "tailwindcss"; :root { --background: hsl(0 0% 100%); } @theme inline { --color-background: var(--background); } @layer base { body { background-color: var(--background); } } ``` --- ### 5. ❌ Build Fails with tailwind.config.ts **Error**: "Unexpected config file" **Cause**: v4 doesn't use `tailwind.config.ts` (v3 legacy) **Solution**: ```bash rm tailwind.config.ts ``` v4 configuration happens in `src/index.css` using `@theme` directive. --- ### 6. ❌ @theme inline Breaks Dark Mode in Multi-Theme Setups **Error**: Dark mode doesn't switch when using `@theme inline` with custom variants (e.g., `data-mode="dark"`) **Source**: [GitHub Discussion #18560](https://github.com/tailwindlabs/tailwindcss/discussions/18560) **Cause**: `@theme inline` bakes variable VALUES into utilities at build time. When dark mode changes the underlying CSS variables, utilities don't update because they reference hardcoded values, not variables. **Why It Happens**: - `@theme inline` inlines VALUES at build time: `bg-primary` → `background-color: oklch(...)` - Dark mode overrides change the CSS variables, but utilities already have baked-in values - The CSS specificity chain breaks **Solution**: Use `@theme` (without inline) for multi-theme scenarios: ```css /* ✅ CORRECT - Use @theme without inline */ @custom-variant dark (&:where([data-mode=dark], [data-mode=dark] *)); @theme { --color-text-primary: var(--color-slate-900); --color-bg-primary: var(--color-white); } @layer theme { [data-mode="dark"] { --color-text-primary: var(--color-white); --color-bg-primary: var(--color-slate-900); } } ``` **When to use inline**: - Single theme + dark mode toggle (like shadcn/ui default) ✅ - Referencing other CSS variables that don't change ✅ **When NOT to use inline**: - Multi-theme systems (data-theme="blue" | "green" | etc.) ❌ - Dynamic theme switching beyond light/dark ❌ **Maintainer Guidance** (Adam Wathan): > "It's more idiomatic in v4 for the actual generated CSS to reference your theme variables. I would personally only use inline when things don't work without it." --- ### 7. ❌ @apply with @layer base/components (v4 Breaking Change) **Error**: `Cannot apply unknown utility class: custom-button` **Source**: [GitHub Discussion #17082](https://github.com/tailwindlabs/tailwindcss/discussions/17082) **Cause**: In v3, classes defined in `@layer base` and `@layer components` could be used with `@apply`. In v4, this is a breaking architectural change. **Why It Happens**: v4 doesn't "hijack" the native CSS `@layer` at-rule anymore. Only classes defined with `@utility` are available to `@apply`. **Migration**: ```css /* ❌ v3 pattern (worked) */ @layer components { .custom-button { @ap
Related in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.