This skill should be used when setting up, configuring, or initializing Tailwind CSS (v3 or v4) and shadcn/ui for Next.js 16 App Router projects.
Configure a production-ready Tailwind CSS (v3/v4) + shadcn/ui setup for Next.js 16 App Router projects. This skill automates dependency installation, configuration, component generation, and provides:
next-themes (class strategy)Before running this skill, verify:
app/ directory)npm install)package.json at project root.tsx/.ts)To verify:
# Check Next.js version
cat package.json | grep "\"next\":"
# Confirm app/ directory exists
ls -la app/
Use AskUserQuestion tool to collect configuration preferences:
next-themes, adds ThemeProvider, creates mode toggleSheet componentExecute the Python setup script to install dependencies and initialize shadcn/ui:
cd /path/to/nextjs-project
python /path/to/skill/scripts/setup_tailwind_shadcn.py
The script will:
components.json for shadcn/uilib/utils.ts with cn() helperCopy and process template files from assets/ directory:
Tailwind Configuration
# Copy and create
cp assets/tailwind.config.ts.template project/tailwind.config.ts
cp assets/postcss.config.js.template project/postcss.config.js
Global Styles
# Copy and replace {{THEME_PRESET}} with user's choice
cp assets/globals.css.template project/app/globals.css
# Replace: {{THEME_PRESET}} → zinc | slate | neutral
Utility Functions
cp assets/lib/utils.ts project/lib/utils.ts
Copy theme and layout components from assets/components/:
Theme Provider (if dark mode enabled)
cp assets/components/theme-provider.tsx project/components/theme-provider.tsx
cp assets/components/mode-toggle.tsx project/components/mode-toggle.tsx
App Shell (if sidebar layout enabled)
cp assets/components/app-shell.tsx project/components/app-shell.tsx
Update or create app/layout.tsx:
# If layout.tsx exists, carefully merge changes
# If not, copy template
cp assets/app/layout.tsx.template project/app/layout.tsx
Key additions:
globals.cssThemeProvider (if dark mode enabled)<Toaster /> from Sonner for notificationsMerge strategy if layout exists:
ThemeProviderToaster before closing body tagsuppressHydrationWarning on <html> tagIf user requested examples, copy example pages:
# Copy home page
cp assets/app/page.tsx.template project/app/page.tsx
# Copy examples directory structure
cp -r assets/app/examples/ project/app/examples/
Example pages include:
app/page.tsx): Hero, features grid, CTAapp/examples/forms/page.tsx): Contact form, validation patternsapp/examples/dialogs/page.tsx): Modal examples, A11y notesapp/examples/theme/page.tsx): Color tokens, customization guideInstall additional components as needed:
# Common components for examples
npx shadcn-ui@latest add dropdown-menu
npx shadcn-ui@latest add sheet
npx shadcn-ui@latest add separator
# Optional: Form components
npx shadcn-ui@latest add form
npx shadcn-ui@latest add checkbox
npx shadcn-ui@latest add select
Consult references/shadcn-component-list.md for full component catalog.
Run checks to ensure setup is complete:
# Check for TypeScript errors
npx tsc --noEmit
# Start dev server
npm run dev
# Open browser to http://localhost:3000
Visual verification:
Add a "Design System & UI" section to project README.md:
## Design System & UI
This project uses Tailwind CSS and shadcn/ui for styling and components.
### Customizing Colors
Edit CSS variables in `app/globals.css`:
```css
:root {
--primary: 270 80% 45%; /* Your brand color (HSL) */
--radius: 0.75rem; /* Border radius */
}
```
Test contrast ratios: https://webaim.org/resources/contrastchecker/
### Adding Components
```bash
# Add any shadcn/ui component
npx shadcn-ui@latest add [component-name]
# Example: Add a combobox
npx shadcn-ui@latest add combobox
```
Available components: https://ui.shadcn.com/docs/components
### Dark Mode
Toggle theme programmatically:
```tsx
import { useTheme } from 'next-themes'
export function Example() {
const { theme, setTheme } = useTheme()
// theme: 'light' | 'dark' | 'system'
// setTheme('dark')
}
```
### Accessibility
- All components meet WCAG 2.1 Level AA
- Focus indicators on all interactive elements
- Keyboard navigation supported
- Screen reader compatible
See `references/accessibility-checklist.md` for full guidelines.
Zinc (default) - Cool, neutral gray tones:
--primary: 240 5.9% 10%;
--muted: 240 4.8% 95.9%;
Slate - Slightly cooler, tech-focused:
--primary: 222.2 47.4% 11.2%;
--muted: 210 40% 96.1%;
Neutral - True neutral grays:
--primary: 0 0% 9%;
--muted: 0 0% 96.1%;
Customize further by editing app/globals.css :root and .dark blocks.
Check Tailwind version before setup:
npm view tailwindcss version
If v4.0.0+ is available:
@theme directive)references/tailwind-v4-migration.mdIf v4 not available (current default):
// TODO: Upgrade to Tailwind v4 when stableIf sidebarLayout = true:
AppShell component with responsive sidebarSheet (slide-over)If sidebarLayout = false:
Users can customize navigation in layout files by passing navigation prop:
<AppShell
navigation={[
{ title: 'Home', href: '/', icon: Home },
{ title: 'About', href: '/about', icon: Info },
]}
siteTitle="My App"
>
{children}
</AppShell>
Cause: Network issues, registry timeout, or package conflicts
Solution:
# Clear npm cache
npm cache clean --force
# Retry with verbose logging
npm install --verbose
# Or use specific registry
npm install --registry https://registry.npmjs.org/
Cause: Missing type definitions or tsconfig issues
Solution:
# Install missing types
npm install --save-dev @types/react @types/react-dom @types/node
# Check tsconfig.json paths
{
"compilerOptions": {
"paths": {
"@/*": ["./*"]
}
}
}
Cause: ThemeProvider not wrapping content, or suppressHydrationWarning missing
Solution:
<html suppressHydrationWarning> in layoutThemeProvider wraps {children}tailwind.config.ts has darkMode: 'class'Cause: components.json misconfigured or components not installed
Solution:
# Reinitialize shadcn/ui
npx shadcn-ui@latest init
# Re-add components
npx shadcn-ui@latest add button card input
Cause: Global CSS focus styles not applied
Solution:
app/globals.css includes focus styles layer*:focus-visible rule is present--ring CSS variable is definedThis skill bundles comprehensive resources for reference:
tailwind-v4-migration.md: Tailwind v3 vs v4 differences, migration guideshadcn-component-list.md: Complete shadcn/ui component catalog with usage examplestheme-tokens.md: Design token system, color customization guideTo read a reference:
# From skill directory
cat references/theme-tokens.md
setup_tailwind_shadcn.py: Main automation script for dependency installation and configurationExecute directly:
python scripts/setup_tailwind_shadcn.py
tailwind.config.ts.template, postcss.config.js.template, globals.css.templatetheme-provider.tsx, mode-toggle.tsx, app-shell.tsxlib/utils.tsapp/layout.tsx.template, app/page.tsx.templateapp/examples/forms/, app/examples/dialogs/, app/examples/theme/Copy and customize as needed for the target project.
After setup, manually toggle dark mode and verify:
[OK] Good (semantic)
<div className="bg-primary text-primary-foreground">
[ERROR] Bad (hard-coded)
<div className="bg-blue-600 text-white">
Use TypeScript for all components:
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
variant?: 'default' | 'destructive' | 'outline'
}
aria-label for icon-only buttonsWhen customizing tokens or components, document changes in project README or inline comments.
After running this skill, recommend users:
Customize brand colors
--primary in app/globals.cssAdd more components
npx shadcn-ui add [component] as neededreferences/shadcn-component-list.md for optionsConfigure responsive breakpoints
screens in tailwind.config.ts if neededSet up linting
eslint-plugin-jsx-a11y for accessibility lintingTest production build
npm run build
npm start
This skill provides a complete, production-ready Tailwind CSS + shadcn/ui setup for Next.js 16 App Router projects. It handles:
[OK] Dependency installation (Tailwind, shadcn/ui, next-themes) [OK] Configuration (Tailwind config, PostCSS, global CSS) [OK] Dark mode setup (ThemeProvider, toggle component) [OK] Base layout (responsive header, optional sidebar) [OK] Design tokens (semantic CSS variables) [OK] Accessibility (WCAG 2.1 AA, keyboard nav, screen readers) [OK] Example pages (forms, dialogs, theme showcase) [OK] Documentation (README updates, customization guides)
The setup is forward-compatible with Tailwind v4 and follows official Anthropic skill best practices.