This feature is currently in preview. Preview features are not covered by semantic versioning and some details may change as we continue to refine them.
Tailwind CSS v2.1 introduces a new just-in-time compiler for Tailwind CSS that generates your styles on-demand as you author your templates instead of generating everything in advance at initial build time.
This comes with a lot of advantages:
- Lightning fast build times. Tailwind can take 3–8s to initially compile using our CLI, and upwards of 30–45s in webpack projects because webpack struggles with large CSS files. This library can compile even the biggest projects in about 800ms (with incremental rebuilds as fast as 3ms), no matter what build tool you're using.
- Every variant is enabled out of the box. Variants like
disabled, and others are not normally enabled by default due to file-size considerations. Since this library generates styles on demand, you can use any variant you want, whenever you want. You can even stack them like
sm:hover:active:disabled:opacity-75. Never configure your variants again.
- Generate arbitrary styles without writing custom CSS. Ever needed some ultra-specific value that wasn't part of your design system, like
top: -113pxfor a quirky background image? Since styles are generated on demand, you can just generate a utility for this as needed using square bracket notation like
top-[-113px]. Works with variants too, like
- Your CSS is identical in development and production. Since styles are generated as they are needed, you don't need to purge unused styles for production, which means you see the exact same CSS in all environments. Never worry about accidentally purging an important style in production again.
- Better browser performance in development. Since development builds are as small as production builds, the browser doesn't have to parse and manage multiple megabytes of pre-generated CSS. In projects with heavily extended configurations this makes dev tools a lot more responsive.
To see it in action, watch our announcement video.
To enable just-in-time mode, set the
mode option to
'jit' in your
Since JIT mode generates your CSS on-demand by scanning your template files, it's crucial that you configure the
purge option in your
tailwind.config.js file with all of your template paths, otherwise your CSS will be empty:
Now when you start your development server or build runner, Tailwind will generate your styles on-demand instead of generating everything in advance.
Behind the scenes, the JIT engine uses its own file-watching system to watch your templates for changes as efficiently as possible.
By default, Tailwind will start a long-running watch process if
NODE_ENV=development, and it will run in one-off mode if
If it appears like your one-off build process is hanging, it's almost certainly because
NODE_ENV=development in your build script. To fix this, you can either set
NODE_ENV=production, or explicitly tell Tailwind not to start a watcher by setting
TAILWIND_MODE=build as part of your script.
Since styles are generated on-demand, there's no need to configure which variants are available for each core plugin.
You can use variants like
even, and more in combination with any utility, without making any changes to your
All variants can be combined together to easily target very specific situations without writing custom CSS.
Many utilities support arbitrary values using a new square bracket notation to indicate that you're "breaking out" of your design system.
This is very useful for building pixel-perfect designs where there are a few elements that need hyper-specific styles, like a carefully positioned background image on a marketing site.
We'll likely add some form of "strict mode" in the future for power-hungry team leads who don't trust their colleagues to use this feature responsibly.
You can make any utility important by adding a
! character to the beginning:
! always goes at the beginning of the utility name, after any variants, but before any prefix:
This can be useful in rare situations where you need to increase specificity because you're at war with some styles you don't control.
This new engine is very close to feature parity with
tailwindcss currently and for most projects I bet you'll find it works exactly as you'd expect.
There are a few items still on our todo list though that we are actively working on:
- Advanced PurgeCSS options like
safelistaren't supported yet since we aren't actually using PurgeCSS. We'll add a way to safelist classes for sure though. For now, a
safelist.txtfile somewhere in your project with all the classes you want to safelist will work fine.
- You can only
@applyclasses that are part of core, generated by plugins, or defined within a
@layerrule. You can't
@applyarbitrary CSS classes that aren't defined within a
We are also ironing out some compatibility issues with certain build tools like Parcel and Snowpack, which you can follow in our issue tracker.
If you run into any other issues or find any bugs, please open an issue so we can fix it.