Tailwind Setup Skill (Vite + shadcn/ui)
Add Tailwind CSS, shadcn/ui, dark-mode theme tokens, and aliases to a React/Vite frontend that talks to a Django backend.
What This Skill Does
- Installs Tailwind (+ Vite plugin) and core shadcn/ui deps (
class-variance-authority,clsx,tailwind-merge,lucide-react). - Updates
vite.config.jsto runtailwindcss()alongside React and adds@alias →./src. - Replaces
src/index.csswith Tailwind entry, then appends theme tokens viascripts/apply-theme.sh(usesassets/tailwind-theme.css) for dark/light palettes. - Sets up shadcn/ui scaffolding:
components.json,jsconfig.jsonaliases, and utilitysrc/lib/utils.js. - Enables class-based dark mode in
tailwind.config.js. - Adds
ThemeContext&ThemeTogglecomponents and wrapsAppwithThemeProvider. - Installs shadcn/ui components (card, field, input, button, table, navigation-menu, label, separator, alert) via CLI.
- Verifies build with
npm --prefix ./frontend run build.
Prerequisites
- React + Vite frontend in
frontend/. - Django backend already set up (used only for proxy alignment).
- Node.js 18+ and npm; mkcert HTTPS recommended.
Setup Summary (see SKILL.md for exact edits)
- Deps:
npm --prefix ./frontend install tailwindcss @tailwindcss/vite class-variance-authority clsx tailwind-merge lucide-react. - Vite config: import
path,tailwindcss; add plugin; addresolve.alias{ '@': path.resolve(__dirname, './src') }. - CSS entry: set
src/index.cssto@import "tailwindcss";. - Theme tokens: run
bash .claude/skills/tailwind-setup/scripts/apply-theme.sh frontend(appends tokens tosrc/index.css). - shadcn scaffolding: create
components.json,jsconfig.json,src/lib/utils.js. - Tailwind config:
darkMode: 'class', content globs for./index.htmland./src/**/*.{js,jsx}. - ThemeProvider + toggle: add
src/contexts/ThemeContext.jsx,src/components/ThemeToggle.jsx; wrap<Router />inApp.jsx; drop toggle into navbar. - shadcn components: run
npx --prefix ./frontend shadcn@latest add ...for card/field/input/button/table/navigation-menu/label/separator/alert. - Build check:
npm --prefix ./frontend run build.
Outputs/Artifacts
- Tailwind + shadcn tokens in
src/index.css. tailwind.config.js,components.json,jsconfig.json,src/lib/utils.js.- Theme context/toggle components added and App wrapped.
- Installed shadcn/ui primitives ready for use.
Notes & Gotchas
- Run theme script from project root and pass
frontendpath arg. - Ensure Vite aliases in
vite.config.jsandjsconfig.jsonmatch. - If you already have CSS content, back it up before replacing with Tailwind import (tokens are appended by the script).
- Add additional content globs to
tailwind.config.jsif you place components elsewhere.