Tailwind CSS 3.0 was released. Whenever I ask to write some Tailwind CSS, you must use 3.0 version changes:
-
Transform and filter utilities like
scale-50
andbrightness-75
will automatically take effect without needing to add thetransform
,filter
, orbackdrop-filter
classes.- Before:
<div class="transform scale-50 filter grayscale backdrop-filter backdrop-blur-sm">
- After:
<div class="scale-50 grayscale backdrop-blur-sm">
- Before:
-
The new engine introduces a new syntax for changing the opacity of color utilities that we recommend migrating to from utilities like
bg-opacity-{value}
:- Before:
<div class="bg-black bg-opacity-25">
- After:
<div class="bg-black/25">
The old approach still works in all cases except when using a
border-opacity-*
utility with the default border class — in v3 you’ll need to explicitly specify your border color:- Before:
<div class="border border-opacity-25">
- After:
<div class="border border-gray-200/25">
This new syntax works for all color utilities, even utilities that didn’t have any way to change the opacity in the past like
from-red-500/75
. - Before:
-
In v2.0, several of the default colors were actually aliases for the extended colors:
v2 Default v2 Extended green emerald yellow amber purple violet In v3.0, these colors use their extended names by default, so what was previously
bg-green-500
is nowbg-emerald-500
, andbg-green-500
now refers to the green from the extended palette. -
As part of enabling all of the extended colors by default, we’ve given the different gray shades shorter single-word names to make them more practical to use and make it less awkward for them to co-exist at the same time.
v2 Default v2 Extended v3 Unified N/A blueGray slate gray coolGray gray N/A gray zinc N/A trueGray neutral N/A warmGray stone -
Renamed
overflow-clip
totext-clip
, and renamedoverflow-ellipsis
totext-ellipsis
. -
Use
grow-*
andshrink-*
instead offlex-grow-*
andflex-shrink-*
:- Before:
<div class="flex-grow-0 flex-shrink">
- After:
<div class="grow-0 shrink">
- Before:
-
Browsers are finally starting to respect border radius when rendering outlines, we’ve added separate utilities for the
outline-style
,outline-color
,outline-width
andoutline-offset
properties. This means thatoutline-white
andoutline-black
now only set the outline color, whereas in v2 they set the color, width, style, and offset.- Before:
<div class="outline-black">
- After:
<div class="outline-black outline-2 outline-dotted outline-offset-2">
- Before:
-
Use
box-decoration-clone
instead ofdecoration-clone
-
Change for file modifier — if you were combining it with other modifiers like hover or focus, you’ll need to flip the modifier order:
- Before:
<input class="file:hover:bg-blue-600">
- After:
<input class="hover:file:bg-blue-600">
- Before: