Skip to main content
Tailwind CSS v4 uses a JavaScript configuration file for advanced customization beyond what’s possible with @theme in CSS. The configuration file allows you to define content sources, plugins, presets, and more.

Basic Configuration

Create a tailwind.config.js or tailwind.config.ts file in your project root:
tailwind.config.ts

Configuration Options

Content

Define which files Tailwind should scan for class names:
string[] | ContentConfig
Files to scan for utility class usage
(string | { raw: string, extension?: string })[]
required
Array of file paths or raw content objects
boolean
Whether to use relative paths from the config file (default: false)

Dark Mode

Configure how dark mode is handled:
DarkModeStrategy
Controls dark mode implementation strategyStrategies:
  • false - No dark mode support
  • 'media' - Use @media (prefers-color-scheme: dark)
  • 'class' - Requires .dark class on html element
  • ['class', string] - Custom class name
  • 'selector' - Like class but uses :where() for specificity control
  • ['selector', string] - Custom selector
  • ['variant', string | string[]] - Complete custom control

Prefix

Add a prefix to all utility classes:
This generates classes like tw-flex, tw-pt-4, etc.
string
Prefix to add to all generated utility classes

Important

Make all utilities !important or scope them to a selector:
boolean | string
Add !important to all utilities or scope to a selector

Blocklist

Prevent specific utilities from being generated:
string[]
Array of utility names to exclude from generation

Presets

Extend or override configuration from another config:
Presets are processed first, and each subsequent config can override values from previous ones. The preset system allows for shareable configuration packages.

TypeScript Support

The config file has full TypeScript support:
tailwind.config.ts

Complete Example

tailwind.config.ts