3 min read
•Question 28 of 38mediumWhat is JIT Mode in Tailwind CSS?
Understanding Just-In-Time compilation.
What You'll Learn
- What JIT mode is
- Benefits
- How it works
What is JIT?
JIT (Just-In-Time) mode generates styles on-demand as you author templates, rather than generating everything upfront.
Since Tailwind v3, JIT is the default and only mode.
Benefits
- Lightning fast builds - Only generates used styles
- All variants enabled - No configuration needed
- Arbitrary values - Use any value
w-[137px] - No dev/prod differences - Same CSS in both
How It Works
Template files → Tailwind scans → Generates only used CSS
index.htmlHTML
<!-- Your code -->
<div class="mt-5 bg-blue-500">
<!-- Tailwind only generates -->
.mt-5 { margin-top: 1.25rem; }
.bg-blue-500 { background-color: #3b82f6; }All Variants Available
index.htmlHTML
<!-- These just work without config -->
<div class="sm:hover:active:disabled:bg-blue-500">
<div class="[&>*]:p-4"> <!-- Arbitrary selector -->Watch Mode
$ terminalBash
npx tailwindcss -i input.css -o output.css --watch