What Is New in Tailwind CSS 2.2
| Category | Highlights |
|---|---|
| New Features | All-new Tailwind CLI, pseudo-element variants (before/after, first-letter/line, selection, marker), peer sibling variants, exhaustive pseudo-class support, caret-color utilities, background-origin utilities. |
| Improvements | Shorthand color opacity syntax, extended arbitrary value support with type-hints, improved PostCSS nesting compatibility, per-side border-color utilities, built-in safelist/transform/extract for JIT. |
| Breaking Changes | Transform, filter, and backdrop-filter classes are no longer required; they are automatically enabled, which may affect conditional toggling logic. |
How does the new Tailwind CLI improve the development workflow?
The new CLI lets you compile Tailwind without any configuration files.
- Run
from any directory.npx tailwindcss -o dist/tailwind.css --watch --jit --purge="./src/**/*.html" - Watch mode automatically rebuilds CSS on file changes.
- Use
--minifyto pipe the output through cssnano for production-ready files. - PostCSS plugins are respected via a
postcss.config.jsfile, so you can keep your existing pipeline.
In practice this means fewer moving parts and faster JIT builds because the CLI is Tailwind-specific.
How can I style pseudo-elements and advanced selectors with Tailwind 2.2?
Tailwind now ships first-party variants for ::before, ::after, ::first-letter, ::first-line, ::selection, ::marker, and sibling selectors.
before:andafter:add content and styling, e.g.<div class="before:block before:bg-blue-500 after:flex after:bg-pink-300"></div>- Use
first-letter:for drop caps:first-letter:text-4xl first-letter:font-bold. - Apply a global text highlight with
selection:bg-pink-200onbodyto cascade. - Style list bullets via
marker:text-gray-500. - Target previous siblings using
peer-*variants, e.g.peer-checked:bg-blue-500for custom checkboxes. - All missing pseudo-classes like
placeholder-shown,only-child,valid, etc., are now available.
This matters if you need fine-grained UI polish without writing custom CSS.
What's new with color opacity and arbitrary values in Tailwind 2.2?
Tailwind now supports opacity directly in color utilities and far more arbitrary value syntax.
- Shorthand opacity:
bg-red-500/25replacesbg-red-500 bg-opacity-25. - Arbitrary opacity via brackets:
bg-red-500/[0.31]. - Arbitrary values can be used on almost any utility:
col-start-[73] placeholder-[#aabbcc] object-[50%]. - When using CSS variables, add a type hint:
text-[color:var(--mystery-var)]to disambiguate.
In practice this reduces class noise and lets you fine-tune designs on the fly.
How have transforms, filters, and border utilities changed in Tailwind 2.2?
Transform and filter utilities are now auto-enabled, and per-side border colors have been added.
- Drop the
transformandfilterwrappers:<div class="scale-50 grayscale backdrop-blur-sm">. - If you previously toggled
transformon hover, switch to toggling the sub-utility directly, e.g.hover:scale-105. - New per-side border color utilities:
border-t-blue-500 border-r-pink-500 border-b-green-500 border-l-yellow-500. - Caret color utilities:
caret-red-500for form field cursors. - Background origin utilities:
bg-origin-border,bg-origin-padding,bg-origin-content.
Watch out for the breaking change around implicit transform/filter activation when migrating existing conditional classes.
Frequently Asked Questions
What command compiles Tailwind CSS using the new CLI?
Run npx tailwindcss -o output.css --watch to compile and watch your files.
How do I enable Just-in-Time mode with the CLI?
Add the --jit flag to the command, for example npx tailwindcss -o dist.css --jit --purge="./src/**/*.html".
Which utility lets me set the cursor color in form fields?
Use the caret-{color} utilities such as caret-red-500.
How can I apply a background color with custom opacity in a single class?
Use the slash syntax like bg-red-500/25 to set a 25% opacity background.
What variant should I use to style the ::before pseudo-element?
Apply the before: prefix, for example before:bg-blue-500 before:block.
How do I target a sibling checkbox state with Tailwind 2.2?
Use the peer-checked: variant on the sibling element, e.g. peer-checked:bg-blue-500.