What every tailwind.config.js key does
A tailwind.config.js file customises the design tokens, scanned files and
build behaviour of Tailwind CSS. This reference lists the top-level
configuration keys with their value type and purpose, and explains the crucial
theme versus theme.extend distinction, searchable by key name.
How it works
Tailwind reads the exported config object at build time, resolves the theme
(defaults merged with your customisations), scans the content globs for class
names and emits only the utilities it finds:
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./src/**/*.{html,js,ts,jsx,tsx}"],
darkMode: "class",
theme: {
extend: {
colors: { brand: "#0a7" },
spacing: { 18: "4.5rem" },
},
},
plugins: [require("@tailwindcss/forms")],
};
Values under theme.extend are merged on top of the defaults, while values
placed directly under theme replace a default scale. prefix, important
and darkMode tune output; plugins registers extra utilities.
Tips and notes
- Prefer
theme.extendso you keep Tailwind’s default scales. - Keep
contentglobs tight but complete — missing paths silently drop classes. darkMode: "class"enables a manual theme toggle;"media"follows the OS.prefix: "tw-"namespaces every utility to avoid collisions with other CSS.- Tailwind v4 moves much config into CSS
@theme; this reference targets the JS config (v3-style).