Tailwind CSS v4
The vendored docs in resources/auto/ are the Markdown (MDX) sources of the official Tailwind CSS docs, one file per page (for example resources/auto/tailwindlabs-tailwindcss.com-main-src-docs-theme.mdx.md). Search them for directives, theme variable namespaces, and variants before writing CSS. For a single utility’s class list, fetch its page source from https://raw.githubusercontent.com/tailwindlabs/tailwindcss.com/main/src/docs/<utility>.mdx (for example padding.mdx).
v4 rules
-
Configure in CSS. Import Tailwind and declare design tokens as theme variables in
@theme; each variable creates matching utilities (--color-primarygivesbg-primary,text-primary, and so on):@import "tailwindcss"; @theme { --color-primary: #1e3a8a; --font-sans: "Inter", sans-serif; } -
Use
@import "tailwindcss";in place of the v3@tailwind base; @tailwind components; @tailwind utilities;directives. -
A legacy JavaScript config still works when loaded explicitly with
@config "./tailwind.config.js";; v4 does not detect it automatically. Prefer@themefor new tokens. -
Content detection is automatic and treats source files as plain text, skipping
.gitignored files. Write complete class names (map a prop to"bg-red-600", never buildbg-${color}-600), and register extra paths with@source "../path";.
Build commands
The v4 CLI ships in the @tailwindcss/cli package:
npx @tailwindcss/cli -i ./src/input.css -o ./dist/output.css # build once
npx @tailwindcss/cli -i ./src/input.css -o ./dist/output.css --watch # rebuild on change
npx @tailwindcss/cli -i ./src/input.css -o ./dist/output.css --minify # minified output
Use the project’s existing entry point instead (a tailwindcss binary on PATH, a package script, or a Vite or PostCSS plugin) when it has one.
Completion criteria
- The build command exits 0 and writes the output file.
- Each class used by the change appears in the compiled CSS (search the output for it), including classes generated from new
@themevariables.