Never Miss a Laravel Release 🚀
Tailwind v2.2 was just released with a brand-new Tailwind CLI tool, a ton of new features using the JIT engine, and more. Let's take a look at some of the new features.
Brand New Tailwind CLI
The Tailwind team released a brand-new tailwindcss CLI from the ground-up, adding support for some nice features to make it convenient to work with Tailwind right away:
npx tailwindcss \ -o dist/tailwind.css \ --watch \ --jit \ --purge="./src/**/*.html"
The above example from the release notes showcases a new watch mode, a --jit flag to build Tailwind with the JIT mode, and the --purge flag used to remove unused classes. The CLI is also backward-compatible with the previous CLI.
Check the updated CLI documentation to learn more about using this option to work with Tailwind without any external build tooling.
Styling Pseudo Elements With JIT
Tailwind now has first-party support for styling pseudo elements using the just-in-time mode:
<div class="before:block before:bg-blue-500 after:flex after:bg-pink-300"></div> <!-- customize pseudo content value --><div class="before:content-['hello'] before:block ..."></div>
Thanks to the JIT compiler added to core in Tailwind CSS v2.1, many new features can leverage this feature without risking bloat to the overall weight of Tailwind builds. That being said, the JIT mode is required to use this feature.
Sibling Selector Variants
New peer-* variants target sibling elements, which is useful for styling elements based on the state of other siblings. The example provided from the release notes is styling an element when a sibling checkbox is checked:
<label> <input type="checkbox" class="peer sr-only"> <span class="h-4 w-4 bg-gray-200 peer-checked:bg-blue-500"> <!-- ... --></label>
Learn More
The Tailwind 2.2.0 release has quite a few new useful features, thanks largely to the JIT engine. You can see the complete list of new features and updates below and the diff between v2.1.4 and v2.2.0 on GitHub.
If you prefer visual learning, Simon Vrachliotis’s What’s New in Tailwind CSS v2.2 has you covered:
The following release notes are directly from the changelog:
2.2.0
Changed
-
JIT: Use “tracking” context by default instead of “watching” context for improved reliability with most bundlers (#4514)
Depending on which tooling you use, you may need to explicitly set
TAILWIND_MODE=watchuntil your build runner has been updated to support PostCSS’sdir-dependencymessage type.
Added
- Add
background-originutilities (#4117) - Improve
@applyperformance in projects that process many CSS sources (#3178) - JIT: Don’t use CSS variables for color utilities if color opacity utilities are disabled (#3984)
- JIT: Redesign
matchUtilitiesAPI to make it more suitable for third-party use (#4232) - JIT: Support applying important utility variants (#4260)
- JIT: Support coercing arbitrary values when the type isn’t detectable (#4263)
- JIT: Support for
rawsyntax inpurgeconfig (#4272) - Add
emptyvariant (#3298) - Update
modern-normalizeto v1.1 (#4287) - Implement
themefunction internally, removepostcss-functionsdependency (#4317) - Add
screenfunction to improve nesting plugin compatibility (#4318) - JIT: Add universal shorthand color opacity syntax (#4348)
- JIT: Add
@tailwind variantsdirective to replace@tailwind screens(#4356) - JIT: Add support for PostCSS
dir-dependencymessages inTAILWIND_DISABLE_TOUCHmode (#4388) - JIT: Add per-side border color utilities (#4404)
- JIT: Add support for
beforeandafterpseudo-element variants andcontentutilities (#4461) - Add new
transformandextractAPIs to simplify PurgeCSS/JIT customization (#4469) - JIT: Add exhaustive pseudo-class and pseudo-element variant support (#4482)
- JIT: Add
caret-colorutilities (#4499) - Rename
lightBluetosky, emit console warning when using deprecated name (#4513) - New CLI with improved JIT support,
--watchmode, and more (#4526, 4558) - JIT: Add new
peer-*variants for styling based on sibling state (#4556) - Expose
safelistas a top-level option underpurgefor both JIT and classic engines (#4580) - JIT: Remove need for
transformclass when using classes likescale-*,rotate-*, etc. (#4604) - JIT: Remove need for
filterandbackdrop-filterclasses when using classes likecontrast-*,backdrop-blur-*, etc. (#4614) - Support passing a custom path for your PostCSS configuration in the Tailwind CLI (#4607)
- Add
blur-noneby default with intent to deprecateblur-0(#4614)
Fixed
- JIT: Improve support for Svelte class bindings (#4187)
- JIT: Improve support for
calcandvarin arbitrary values (#4147) - Convert
hslcolors tohslawhen transforming for opacity support instead ofrgba(#3850) - Fix
backdropBlurvariants not being generated (#4188) - Improve animation value parsing (#4250)
- Ignore unknown object types when hashing config (82f4eaa)
- Ensure variants are grouped properly for plugins with order-dependent utilities (#4273)
- JIT: Fix temp file storage when node temp directories are kept on a different drive than the project itself (#4044)
- Support border-opacity utilities alongside default
borderutility (#4277) - JIT: Fix source maps for expanded
@tailwinddirectives (2f15411) - JIT: Ignore whitespace when collapsing adjacent rules (15642fb)
- JIT: Generate group parent classes correctly when using custom separator (#4508)
- JIT: Fix incorrect stacking of multiple
groupvariants (#4551) - JIT: Fix memory leak due to holding on to unused contexts (#4571)
Internals
- Add integration tests for popular build runners (#4354)