Learn how to use TailwindCSS in Aurelia 2 with this detailed guide.
What is Tailwind CSS?
Tailwind CSS is a highly customizable, low-level CSS framework that gives you all of the building blocks you need to build bespoke designs without any annoying opinionated styles you have to fight to override.
How to configure an Aurelia 2 project with Tailwind CSS v4?
Tailwind CSS 4.1 introduces a simplified setup: install Tailwind, add the official plugin for your bundler, then import tailwindcss once inside your stylesheet. No @next tags, no tailwind.config.js (unless you want customizations), and no manual content paths.
Step 1: Create an Aurelia project
npxmakesaurelia
Choose your preferred bundler. The steps below highlight Vite first, followed by Webpack, Parcel, and the standalone CLI.
If you aren’t using a bundler, wire up the CLI directly:
The CLI watches your HTML entry file and any imports it discovers, so the build remains tree-shaken even without a config file.
Step 4: Import Tailwind once
Add this line to the top of your root stylesheet (for example src/my-app.css):
This single import injects Tailwind’s base, component, and utility layers. The old @tailwind base; / @tailwind utilities; directives aren’t used in v4.
Step 5: Run the project
Tailwind’s compiler runs alongside your bundler, so editing Aurelia templates immediately updates the generated CSS.
How to test Tailwind styles quickly
Insert the following snippet into any view:
Seeing the styled alert confirms that Tailwind’s classes are available in your bundle.
Content detection & build optimization
Tailwind v4 automatically scans your project for class usage, removing unused styles during both dev and production builds. You no longer set content: [] in tailwind.config.js. If you need to extend the theme or register plugins, create a config manually:
Aurelia class bindings: Tailwind’s scanner looks for class names in attribute values. If you put a Tailwind class only in an Aurelia .class attribute name (for example width-[360px].class="condition"), Tailwind may not detect it and it won’t be generated.
Prefer class.bind with the object form (quote keys for Tailwind classes):
During npm run build, Tailwind’s compiler and Lightning CSS minify the stylesheet and automatically add vendor prefixes.
Migrating from Tailwind v3
Replace the old @tailwind base/components/utilities directives with @import "tailwindcss";
Uninstall autoprefixer and postcss unless another tool in your stack needs them—Tailwind v4 handles prefixing internally.
Remove manual content arrays unless you want to override the automatic detection.
Install the new plugin for your bundler (@tailwindcss/vite, @tailwindcss/postcss, or @tailwindcss/cli).
After migrating, you benefit from zero-config tree shaking, smaller CSS bundles, and much faster incremental builds.