How do I set up the Tailwind build and purge configuration for Hyvä?
To set up the Hyvä Tailwind configuration, tell Tailwind which template folders to scan, then compile web/css/styles.css with npm. Hyvä 1.4 and later (Tailwind v4) read scan paths from @source lines in web/tailwind/tailwind-source.css. Parent theme and module folders go in hyva.config.json. Hyvä 1.3.x and earlier use a JavaScript file, tailwind.config.js, instead.
Since Tailwind v3, there is no separate purge step. Tailwind generates only the classes it finds in your scan paths, so a missing path means silently missing styles.
Quick answer
Hyvä 1.4+ uses Tailwind v4, built from app/design/frontend/Vendor/Theme/web/tailwind after npm install. The theme’s tailwind-source.css scans templates through @source "../../**/*.phtml" and @source "../../**/*.xml". The parent theme goes under tailwind.include in hyva.config.json, which npx hyva-init creates. npm run build writes a minified web/css/styles.css, and npm run watch rebuilds during development. Hyvä 1.2.x and 1.3.x run Tailwind v3, so these globs go in the content array of tailwind.config.js.
Hyvä Tailwind configuration on v4 vs v3
| Hyvä 1.4+ (Tailwind v4) | Hyvä 1.2.x to 1.3.x (Tailwind v3) | |
|---|---|---|
| Template scan paths | @source in tailwind-source.css | content array in tailwind.config.js |
| Parent theme and module paths | include / exclude in hyva.config.json | mergeTailwindConfig plus manual content entries |
| Colors and spacing | @theme in CSS, or tokens in hyva.config.json | theme in tailwind.config.js |
| Safelisting | @source inline() (Tailwind v4.1+) | safelist array |
| Build output | web/css/styles.css | web/css/styles.css |
Hyvä 1.0.x and 1.1.x used Tailwind v2, which nests the paths under purge.content. Version mapping per Hyvä’s Tailwind docs.
Hyvä Tailwind configuration on 1.4 and later (Tailwind v4)
Hyvä 1.4.0 (released 10 November 2025) moved the default theme to Tailwind v4. The 1.5.x release line uses the same setup, per Hyvä’s default theme changelog.

Step 1: Install the theme’s npm dependencies in web/tailwind
Open a terminal in your theme’s Tailwind folder and install the packages:
cd app/design/frontend/Vendor/Theme/web/tailwind
npm install
Check the engines field in package.json for the required Node.js version. For a child theme, first copy the parent’s whole web/tailwind folder into your theme, leaving out node_modules.
Step 2: Set the scan paths in tailwind-source.css
Start in web/tailwind/tailwind-source.css, which holds most of the Hyvä Tailwind configuration on 1.4 and later. The default file begins like this:
@import "@hyva-themes/hyva-modules/css";
@import "tailwindcss" source(none);
@source "../../**/*.phtml";
@source "../../**/*.xml";
Hyvä’s Tailwind content settings docs cover the automatic and manual options.
source(none) turns off Tailwind’s automatic file detection, so only your @source paths are scanned. Paths are relative to the CSS file, and ../../ points at your theme root. Add another @source line if your theme keeps classes in other file types, such as .html or .js. In Tailwind v4, theme colors and spacing live in CSS through the @theme directive, replacing the theme section of tailwind.config.js.
Step 3: Add module and parent paths to the Hyvä Tailwind config
Run npx hyva-init in web/tailwind to create hyva.config.json. Its include list points the Hyvä Tailwind configuration at folders beyond your theme, like the parent theme in vendor/. A child theme of the Hyvä default theme needs the parent included:
{
"tailwind": {
"include": [
{ "src": "vendor/hyva-themes/magento2-default-theme" }
],
"exclude": []
}
}
Use magento2-default-theme-csp instead if that is the parent you installed. If your parent is itself a child theme, include both the parent and the Hyvä default theme.
Hyvä compatibility modules registered in app/etc/hyva-themes.json get picked up automatically. That file updates during bin/magento setup:upgrade, or on demand with bin/magento hyva:config:generate. Use exclude to drop a module whose templates you never render.
Step 4: Compile styles.css with npm run build
Run npm run watch from web/tailwind while you work. It recompiles whenever a scanned file changes. Run npm run build for a minified production stylesheet. Both commands first run npx hyva-sources, which rebuilds generated/hyva-source.css from hyva.config.json and app/etc/hyva-themes.json. tailwind-source.css imports that file, so module and parent theme templates get scanned too. If npm run build reports a missing script, your package.json uses the older name build-prod. The output lands in web/css/styles.css.
Hyvä Tailwind config on 1.3.x and older (Tailwind v3 and v2)
Before Hyvä 1.4, all scan paths sat in the content array of tailwind.config.js:
module.exports = {
content: [
'../../**/*.phtml',
'../../*/layout/*.xml',
'../../../../../../../vendor/hyva-themes/magento2-default-theme/**/*.phtml',
'../../../../../../../vendor/hyva-themes/magento2-default-theme/*/layout/*.xml',
],
};
Tailwind v2 themes on Hyvä 1.1.x nest the same array under purge.content. Hyvä 1.1.14 and later include a mergeTailwindConfig helper. It pulls compatibility module paths into your Hyvä Tailwind configuration automatically, as Hyvä’s config merging docs explain. Build from the theme’s web/tailwind folder with npm run watch during development and npm run build for production.
What the Hyvä Tailwind configuration won’t catch
- Tailwind cannot see class names you build from strings in PHP or Alpine.js. Write full class names in templates. To safelist classes, use the
safelistarray intailwind.config.json Tailwind v3, or@source inline("...")intailwind-source.csson Tailwind v4.1+. - Tailwind v4 needs Safari 16.4+, Chrome 111+ or Firefox 128+, per Hyvä’s Tailwind 4 upgrade guide. Stay on v3 if you must support older browsers.
- An allow-list
.gitignorethat starts with*can stop Tailwind v4 from scanning the parent theme invendor/. Hyvä’s Tailwind FAQ recommends a deny-list.gitignoreinstead. - Build
styles.cssbeforesetup:static-content:deployin production mode, as Hyvä’s deployment docs require, or the deployed CSS stays stale. - Classes inside CMS or Page Builder content live in the database, so the theme build never scans them. The
Hyva_CmsTailwindJitmodule compiles those classes. It installs automatically with Hyvä CMS, but Page Builder stores need to install it separately. Our answer on custom widgets and CMS blocks walks through the setup.
How to check whether your theme uses Tailwind v3 or v4
Check your installed version with composer show "hyva-themes/*". A hyva.config.json file in web/tailwind also means the theme runs Tailwind v4 (Hyvä 1.4+). Hyvä’s troubleshooting guide names the purge settings as the first check for missing styles. Start there: audit the scan paths in your Hyvä Tailwind configuration before debugging anything else. If you’re planning a v3 to v4 move across several themes, our Hyvä theme development team can help scope it.
Related Answers
Still need help?
Stuck on a Hyvä Tailwind build?
If classes are missing from styles.css or a v3 to v4 migration is stalling, our Hyvä engineers can review your config.