Tailwind config generator — v4 @theme CSS or v3 tailwind.config.js

List your brand colours, fonts and extra breakpoints, and the tool writes the Tailwind setup for them, a CSS @theme block for Tailwind v4 or a tailwind.config.js for v3, plus the npm install line.

Live demo · real result from this tool
Tailwind version
Dark mode

app.css

/* app.css — Tailwind CSS v4 is configured in CSS; no tailwind.config.js is needed. */@import "tailwindcss"; /* Dark mode follows a .dark class instead of the OS setting */@custom-variant dark (&:where(.dark, .dark *)); /* Each variable creates utilities: --color-brand → bg-brand, text-brand, … */@theme {  --color-brand: #4f46e5;  --color-accent: #f59e0b;  --color-ink: oklch(0.21 0.03 265);  --font-sans: Inter, ui-sans-serif, system-ui, sans-serif;  --font-mono: "JetBrains Mono", ui-monospace, monospace;  --breakpoint-3xl: 120rem;} 

Install

npm install tailwindcss @tailwindcss/vite

Tailwind v4 detects your source files automatically and reads its theme from @theme in CSS. Import this file from your entry point.

Processed on your device — nothing is uploaded.

How to use the Tailwind config generator

  1. Choose the Tailwind version: v4 (CSS-first) or v3 (tailwind.config.js).
  2. List Colours (name: value), one per line, for example brand: #4f46e5. Hex, rgb and oklch values all work.
  3. Enter Sans font families (comma-separated) and Monospace font families.
  4. Add Extra breakpoints (name: width) such as 3xl: 120rem, choose Dark mode (Follow the OS or .dark class) and tick the Typography plugin or Forms plugin.
  5. For v3 only, check the Content paths (v3). Then run the install command and save the file.

What it does and when to use it

Most Tailwind projects add brand colours, a chosen font and sometimes a wider breakpoint to the defaults. Where those go changed between versions: v3 used a JavaScript config, v4 moved the theme into CSS. The Tailwind docs on theme variables explain the v4 approach in full.

Use it when you start a Tailwind project or move design tokens into Tailwind. If you write plain CSS rather than Tailwind, the CSS variables generator produces the same kind of tokens as :root custom properties. Tailwind v4 projects usually run on Vite; the Vite config generator can add the Tailwind plugin. For breakpoints in hand-written CSS, see the media query generator.

How it works

v4. The file starts with @import "tailwindcss";, then one @plugin line per ticked plugin. With the .dark class option it adds @custom-variant dark (&:where(.dark, .dark *));. Inside @theme, colours become --color-<name>, fonts become --font-sans and --font-mono, and breakpoints become --breakpoint-<name>. Names are lower-cased with spaces turned into hyphens.

v3. The file exports an object with content, darkMode ('selector' or 'media') and theme.extend, so your values are added to Tailwind’s defaults rather than replacing them. Plugins are imported at the top.

Font names with spaces are quoted, and a system fallback stack is always added after your fonts.

Worked examples

Default v4 setup.

@theme {
  --color-brand: #4f46e5;
  --color-accent: #f59e0b;
  --color-ink: oklch(0.21 0.03 265);
  --font-sans: Inter, ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --breakpoint-3xl: 120rem;
}

Install: npm install tailwindcss @tailwindcss/vite.

The same values for v3 with Typography. The file begins import plugin0 from '@tailwindcss/typography';, sets darkMode: 'selector', and lists brand: '#4f46e5', under theme.extend.colors.

One colour, OS dark mode, Forms plugin. v4, colour primary: #0f766e, sans font Source Sans 3, no mono font or breakpoints. The output has @plugin "@tailwindcss/forms";, no custom-variant line, and --font-sans: "Source Sans 3", ui-sans-serif, system-ui, sans-serif;.

Limits and tips

  • Colour values are not checked. A typo such as #4f46e passes through; check the result in the browser.
  • Shades are not generated. brand is one colour, not a 50–950 scale; add brand-600 lines yourself if you need steps.
  • Prefer v4 for new projects; v3 is the previous major version.

Frequently asked questions

Where is tailwind.config.js in Tailwind v4?
Tailwind v4 does not need one. Theme values live in CSS inside @theme, plugins are added with @plugin, and source files are found automatically.
How do I use the colours after generating?
Each colour becomes utilities named after it. brand gives bg-brand, text-brand, border-brand and so on. In v4 the value is also a CSS variable, var(--color-brand), that you can use in your own CSS.
Does this load my fonts?
No. It only tells Tailwind which font names to use, followed by system fallbacks. You still need to load the font files, for example by self-hosting them with @font-face.
Which dark mode option should I choose?
Follow the OS uses the visitor's system setting through prefers-color-scheme. The .dark class option lets you add a toggle, because dark styles apply whenever an element above has the class dark.
The install line uses @tailwindcss/vite. What if I do not use Vite?
The v4 install command assumes Vite. For other setups, Tailwind offers a PostCSS plugin and a CLI; install those instead and keep the generated CSS as it is.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close