//
Search across all documentation pages
🤖 Read the SystemsArchitect.io Blog for over 100+ cloud architecture articles 🔥
These skill recipes are designed for Claude Code but also work with other AI coding agents that support skill/instruction files.
The complete SKILL.md content you can copy into .claude/skills/tailwind-v4-shadcn/SKILL.md:
---
name: tailwind-v4-shadcn
description: "Mastering Tailwind CSS v4 + shadcn/ui component architecture and styling. Use when asked to: tailwind help, shadcn component, styling, theming, dark mode, CSS variables, responsive design, animation, Tailwind v4 config."
allowed-tools: "Read, Write, Edit, Glob, Grep, Bash(npm:*), Bash(npx:*), Bash(pnpm:*), Agent"
---
# Tailwind v4 + shadcn/ui
You are a Tailwind CSS v4 and shadcn/ui expert. Provide authoritative guidance on styling, theming, and component architecture.
## Tailwind v4 Key Changes from v3
Tailwind v4 uses a CSS-first configuration model. There is no more tailwind.config.js by default.
### CSS-First Configuration
```css
/* app/globals.css */
@import "tailwindcss";
/* Custom theme values */
@theme \{
--color-primary: oklch(0.7 0.15 240);
--color-primary-foreground: oklch(0.98 0.01 240);
--color-secondary: oklch(0.6 0.1 280);
--color-secondary-foreground: oklch(0.98 0.01 280);
--color-accent: oklch(0.8 0.12 160);
--font-sans: "Inter", sans-serif;
--font-mono: "JetBrains Mono", monospace;
--radius-lg: 0.75rem;
--radius-md: 0.5rem;
--radius-sm: 0.25rem;
--breakpoint-xs: 30rem;
--animate-slide-in: slide-in 0.3s ease-out;
\}
@keyframes slide-in \{
from \{ transform: translateY(10px); opacity: 0; \}
to \{ transform: translateY(0); opacity: 1; \}
\}tailwind.config.js is optional (CSS-first via @theme)@apply is discouraged (use component extraction instead)theme() function replaced by CSS variablesbg-opacity-* replaced by bg-black/50 syntax@container, @sm, @md, @lgrotate-x-*, rotate-y-*, perspective-*text-wrap-balance, text-wrap-prettyfield-sizing-content for auto-sizing textareascolor-scheme-* for system color schemes@media (prefers-color-scheme: dark)npx shadcn@latest init
npx shadcn@latest add button card dialog form inputimport \{ clsx, type ClassValue \} from "clsx";
import \{ twMerge \} from "tailwind-merge";
export function cn(...inputs: ClassValue[]) \{
return twMerge(clsx(inputs));
\}
// Usage
<div className=\{cn(
"rounded-lg border p-4",
isActive && "border-primary bg-primary/10",
className // allow parent override
)\} />// components/ui/card.tsx - shadcn base
const Card = forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
(\{ className, ...props \}, ref) => (
<div
ref=\{ref\}
className=\{cn(
"rounded-lg border bg-card text-card-foreground shadow-sm",
className
)\}
\{...props\}
/>
)
);
// Your composed component
function ProductCard(\{ product \}: \{ product: Product \}) \{
return (
<Card className="hover:shadow-md transition-shadow">
<CardHeader>
<CardTitle>\{product.name\}</CardTitle>
<CardDescription>\{product.category\}</CardDescription>
</CardHeader>
<CardContent>
<p className="text-2xl font-bold">$\{product.price\}</p>
</CardContent>
<CardFooter>
<Button className="w-full">Add to Cart</Button>
</CardFooter>
</Card>
);
\}/* app/globals.css */
@import "tailwindcss";
@theme inline \{
--color-background: var(--background);
--color-foreground: var(--foreground);
--color-card: var(--card);
--color-card-foreground: var(--card-foreground);
--color-primary: var(--primary);
--color-primary-foreground: var(--primary-foreground);
--color-secondary: var(--secondary);
--color-secondary-foreground: var(--secondary-foreground);
--color-muted: var(--muted);
--color-muted-foreground: var(--muted-foreground);
--color-accent: var(--accent);
--color-accent-foreground: var(--accent-foreground);
--color-destructive: var(--destructive);
--color-border: var(--border);
--color-input: var(--input);
--color-ring: var(--ring);
--radius-sm: calc(var(--radius) - 4px);
--radius-md: calc(var(--radius) - 2px);
--radius-lg: var(--radius);
--radius-xl: calc(var(--radius) + 4px);
\}
:root \{
--background: oklch(1 0 0);
--foreground: oklch(0.145 0 0);
--card: oklch(1 0 0);
--card-foreground: oklch(0.145 0 0);
--primary: oklch(0.205 0 0);
--primary-foreground: oklch(0.985 0 0);
--secondary: oklch(0.97 0 0);
--secondary-foreground: oklch(0.205 0 0);
--muted: oklch(0.97 0 0);
--muted-foreground: oklch(0.556 0 0);
--accent: oklch(0.97 0 0);
--accent-foreground: oklch(0.205 0 0);
--destructive: oklch(0.577 0.245 27.325);
--border: oklch(0.922 0 0);
--input: oklch(0.922 0 0);
--ring: oklch(0.708 0 0);
--radius: 0.625rem;
\}
.dark \{
--background: oklch(0.145 0 0);
--foreground: oklch(0.985 0 0);
--card: oklch(0.145 0 0);
--card-foreground: oklch(0.985 0 0);
--primary: oklch(0.985 0 0);
--primary-foreground: oklch(0.205 0 0);
--secondary: oklch(0.269 0 0);
--secondary-foreground: oklch(0.985 0 0);
--muted: oklch(0.269 0 0);
--muted-foreground: oklch(0.708 0 0);
--accent: oklch(0.269 0 0);
--accent-foreground: oklch(0.985 0 0);
--destructive: oklch(0.577 0.245 27.325);
--border: oklch(0.269 0 0);
--input: oklch(0.269 0 0);
--ring: oklch(0.439 0 0);
\}"use client";
import \{ useTheme \} from "next-themes";
import \{ Button \} from "@/components/ui/button";
import \{ Moon, Sun \} from "lucide-react";
export function ThemeToggle() \{
const \{ theme, setTheme \} = useTheme();
return (
<Button
variant="ghost"
size="icon"
onClick=\{() => setTheme(theme === "dark" ? "light" : "dark")\}
>
<Sun className="h-5 w-5 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" />
<Moon className="absolute h-5 w-5 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" />
<span className="sr-only">Toggle theme</span>
</Button>
);
\}// Mobile-first responsive design
<div className="
grid
grid-cols-1 // mobile: single column
sm:grid-cols-2 // 640px+: 2 columns
lg:grid-cols-3 // 1024px+: 3 columns
xl:grid-cols-4 // 1280px+: 4 columns
gap-4
p-4 sm:p-6 lg:p-8
">
// Container queries (new in v4)
<div className="@container">
<div className="@sm:flex @sm:gap-4 @lg:grid @lg:grid-cols-3">
\{/* Responds to container width, not viewport */\}
</div>
</div>// Tailwind built-in animations
<div className="animate-spin" /> // spinner
<div className="animate-pulse" /> // skeleton loading
<div className="animate-bounce" /> // attention
// Custom animations with @theme
// In globals.css:
// @theme \{ --animate-fade-in: fade-in 0.5s ease-out; \}
// @keyframes fade-in \{ from \{ opacity: 0; \} to \{ opacity: 1; \} \}
<div className="animate-fade-in" />
// Transition patterns
<button className="
transition-colors duration-200
bg-primary hover:bg-primary/90
active:scale-95 transition-transform
" />
// For complex animations, use Framer Motion with Tailwind
import \{ motion \} from "framer-motion";
<motion.div
initial=\{\{ opacity: 0, y: 20 \}\}
animate=\{\{ opacity: 1, y: 0 \}\}
className="rounded-lg border bg-card p-6"
/>w-[347px] is a smell; use the design scale
## Working Example
### Example 1: User asks "Help me set up theming for my app"
**User prompt:** "I want a blue-themed app with dark mode support using shadcn/ui."
**Skill-guided response would produce:**
- CSS variables for a blue color palette in oklch
- Light and dark theme definitions
- next-themes provider setup
- Theme toggle component
- Example components using the theme tokens
### Example 2: User asks "How do I customize a shadcn Button?"
**User prompt:** "I want to add a 'gradient' variant to the shadcn Button."
**Skill-guided response would produce:**
```tsx
// components/ui/button.tsx - Add to existing variants
const buttonVariants = cva(
"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",
{
variants: {
variant: {
default: "bg-primary text-primary-foreground hover:bg-primary/90",
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
ghost: "hover:bg-accent hover:text-accent-foreground",
link: "text-primary underline-offset-4 hover:underline",
// NEW: gradient variant
gradient: "bg-gradient-to-r from-primary to-accent text-primary-foreground hover:opacity-90",
},
size: {
default: "h-10 px-4 py-2",
sm: "h-9 rounded-md px-3",
lg: "h-11 rounded-md px-8",
icon: "h-10 w-10",
},
},
defaultVariants: {
variant: "default",
size: "default",
},
}
);
This skill provides:
mkdir -p .claude/skills/tailwind-v4-shadcn
# Paste the Recipe content into .claude/skills/tailwind-v4-shadcn/SKILL.md@sm: and similar queries will not work.class strategy (.dark class on html element), not media (prefers-color-scheme). Make sure next-themes is configured to match.| Approach | When to Use |
|---|---|
| CSS Modules | Component-scoped styles without utility classes |
| Styled Components | CSS-in-JS with dynamic theming |
| Panda CSS | Type-safe CSS-in-JS with build-time extraction |
| Vanilla Extract | Zero-runtime CSS-in-TypeScript |
| Radix Themes | Pre-built component library (less customizable than shadcn) |
| Park UI | shadcn-like components for Ark UI |
@theme in your CSS filetailwind.config.js is optional and no longer the default@import "tailwindcss";
@theme {
--color-primary: oklch(0.7 0.15 240);
--font-sans: "Inter", sans-serif;
--radius-lg: 0.75rem;
--animate-slide-in: slide-in 0.3s ease-out;
}@theme directive inside your CSS file--category-name: value@apply is discouraged (use component extraction instead)theme() function replaced by CSS variablesbg-opacity-* replaced by slash syntax like bg-black/50ring-3 instead of ring)import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}clsx (conditional classes) with twMerge (resolves Tailwind conflicts)twMerge, conflicting classes like p-4 and p-6 would both applycomponents/ui/ -- they live in your codebasecn() for conditional classesclass strategy (.dark class on the html element), not media (prefers-color-scheme):root and dark overrides in .darknext-themes for the toggle, configured to match the class strategy@container on the parent element@container class on the parent, @sm:, @md:, @lg: will not respond@container, @sm, @md, @lgrotate-x-*, rotate-y-*, perspective-*text-wrap-balance, text-wrap-prettyfield-sizing-content for auto-sizing textareastwMerge will not recognize your custom classesimport { cn } from "@/lib/utils";
interface CardProps extends React.HTMLAttributes<HTMLDivElement> {
variant?: "default" | "outlined";
}
function Card({ className, variant, ...props }: CardProps) {
return (
<div
className={cn("rounded-lg bg-card p-4", className)}
{...props}
/>
);
}React.HTMLAttributes<HTMLDivElement> to inherit className and all native div props@apply extensively instead of extracting componentscn() which causes class conflictsw-[347px] too often instead of the design scaleReviewed by Chris St. John·Last updated Jul 10, 2026
🤖 Read the SystemsArchitect.io Blog for over 100+ cloud architecture articles 🔥