T
ToolsOx

Free Tailwind CSS v4 Cheat Sheet Online - Quick Reference Guide

Complete Tailwind CSS v4 cheat sheet with all utility classes. Free online quick reference guide for Tailwind v4. No signup needed.

2730
Total Utilities
526
New in v4
7
Renamed
18
Categories

Tailwind CSS Cheat Sheet Download Free v4 Latest

Get the complete PDF with all utilities, branding & reference URLs

ClassCSS OutputActions
block
display: block;
inline-block
display: inline-block;
inline
display: inline;
flex
display: flex;
inline-flex
display: inline-flex;
grid
display: grid;
inline-grid
display: inline-grid;
hidden
display: none;
table
display: table;
table-row
display: table-row;
table-cell
display: table-cell;
table-caption
display: table-caption;
table-column
display: table-column;
table-column-group
display: table-column-group;
table-footer-group
display: table-footer-group;
table-header-group
display: table-header-group;
table-row-group
display: table-row-group;
contents
display: contents;
list-item
display: list-item;
flow-root
display: flow-root;
static
position: static;
fixed
position: fixed;
absolute
position: absolute;
relative
position: relative;
sticky
position: sticky;
container
width: 100%; max-width: varies;
inset-0
inset: 0px;
inset-auto
inset: auto;
inset-x-0
left: 0px; right: 0px;
inset-y-0
top: 0px; bottom: 0px;
top-0
top: 0px;
right-0
right: 0px;
bottom-0
bottom: 0px;
left-0
left: 0px;
top-auto
top: auto;
right-auto
right: auto;
bottom-auto
bottom: auto;
left-auto
left: auto;
z-0
z-index: 0;
z-10
z-index: 10;
z-20
z-index: 20;
z-30
z-index: 30;
z-40
z-index: 40;
z-50
z-index: 50;
z-auto
z-index: auto;
-z-10
z-index: -10;
-z-20
z-index: -20;
visible
visibility: visible;
invisible
visibility: hidden;
collapse
visibility: collapse;
box-border
box-sizing: border-box;
box-content
box-sizing: content-box;
box-decoration-clonev3: decoration-clone
box-decoration-break: clone;
box-decoration-slicev3: decoration-slice
box-decoration-break: slice;
float-left
float: left;
float-right
float: right;
float-none
float: none;
float-startNEW
float: inline-start;
float-endNEW
float: inline-end;
clear-left
clear: left;
clear-right
clear: right;
clear-both
clear: both;
clear-none
clear: none;
clear-startNEW
clear: inline-start;
clear-endNEW
clear: inline-end;
isolate
isolation: isolate;
isolation-auto
isolation: auto;
object-contain
object-fit: contain;
object-cover
object-fit: cover;
object-fill
object-fit: fill;
object-none
object-fit: none;
object-scale-down
object-fit: scale-down;
object-bottom
object-position: bottom;
object-center
object-position: center;
object-left
object-position: left;
object-right
object-position: right;
object-top
object-position: top;
object-left-bottom
object-position: left bottom;
object-left-top
object-position: left top;
object-right-bottom
object-position: right bottom;
object-right-top
object-position: right top;
overflow-auto
overflow: auto;
overflow-hidden
overflow: hidden;
overflow-visible
overflow: visible;
overflow-scroll
overflow: scroll;
overflow-x-auto
overflow-x: auto;
overflow-y-auto
overflow-y: auto;
overflow-x-hidden
overflow-x: hidden;
overflow-y-hidden
overflow-y: hidden;
overflow-x-clipNEW
overflow-x: clip;
overflow-y-clipNEW
overflow-y: clip;
overscroll-auto
overscroll-behavior: auto;
overscroll-contain
overscroll-behavior: contain;
overscroll-none
overscroll-behavior: none;
overscroll-x-contain
overscroll-behavior-x: contain;
overscroll-y-contain
overscroll-behavior-y: contain;
overscroll-x-none
overscroll-behavior-x: none;
overscroll-y-none
overscroll-behavior-y: none;
aspect-auto
aspect-ratio: auto;
aspect-square
aspect-ratio: 1 / 1;
aspect-video
aspect-ratio: 16 / 9;
columns-1
columns: 1;
columns-2
columns: 2;
columns-3
columns: 3;
columns-4
columns: 4;
columns-5
columns: 5;
columns-6
columns: 6;
columns-7
columns: 7;
columns-8
columns: 8;
columns-9
columns: 9;
columns-10
columns: 10;
columns-11
columns: 11;
columns-12
columns: 12;
columns-auto
columns: auto;
columns-3xsNEW
columns: 16rem;
columns-2xsNEW
columns: 18rem;
columns-xsNEW
columns: 20rem;
columns-smNEW
columns: 24rem;
columns-mdNEW
columns: 28rem;
columns-lgNEW
columns: 32rem;
columns-xlNEW
columns: 36rem;
columns-2xlNEW
columns: 42rem;
columns-3xlNEW
columns: 48rem;
columns-4xlNEW
columns: 56rem;
columns-5xlNEW
columns: 64rem;
columns-6xlNEW
columns: 72rem;
columns-7xlNEW
columns: 80rem;
break-before-auto
break-before: auto;
break-before-avoid
break-before: avoid;
break-before-page
break-before: page;
break-before-column
break-before: column;
break-after-auto
break-after: auto;
break-after-avoid
break-after: avoid;
break-after-page
break-after: page;
break-after-column
break-after: column;
break-inside-auto
break-inside: auto;
break-inside-avoid
break-inside: avoid;
break-inside-avoid-page
break-inside: avoid-page;
break-inside-avoid-column
break-inside: avoid-column;
contain-noneNEW
contain: none;
contain-contentNEW
contain: content;
contain-strictNEW
contain: strict;
contain-sizeNEW
contain: size;
contain-inline-sizeNEW
contain: inline-size;
contain-layoutNEW
contain: layout;
contain-paintNEW
contain: paint;
contain-styleNEW
contain: style;
@containerNEW
container-type: inline-size;
@container-normalNEW
container-type: normal;
@container-sizeNEW
container-type: size;
inset-0.5
inset: 0.125rem;
top-0.5
top: 0.125rem;
right-0.5
right: 0.125rem;
bottom-0.5
bottom: 0.125rem;
left-0.5
left: 0.125rem;
inset-x-0.5
left: 0.125rem; right: 0.125rem;
inset-y-0.5
top: 0.125rem; bottom: 0.125rem;
inset-1
inset: 0.25rem;
top-1
top: 0.25rem;
right-1
right: 0.25rem;
bottom-1
bottom: 0.25rem;
left-1
left: 0.25rem;
inset-x-1
left: 0.25rem; right: 0.25rem;
inset-y-1
top: 0.25rem; bottom: 0.25rem;
inset-2
inset: 0.5rem;
top-2
top: 0.5rem;
right-2
right: 0.5rem;
bottom-2
bottom: 0.5rem;
left-2
left: 0.5rem;
inset-x-2
left: 0.5rem; right: 0.5rem;
inset-y-2
top: 0.5rem; bottom: 0.5rem;
inset-4
inset: 1.0rem;
top-4
top: 1.0rem;
right-4
right: 1.0rem;
bottom-4
bottom: 1.0rem;
left-4
left: 1.0rem;
inset-x-4
left: 1.0rem; right: 1.0rem;
inset-y-4
top: 1.0rem; bottom: 1.0rem;
inset-8
inset: 2.0rem;
top-8
top: 2.0rem;
right-8
right: 2.0rem;
bottom-8
bottom: 2.0rem;
left-8
left: 2.0rem;
inset-x-8
left: 2.0rem; right: 2.0rem;
inset-y-8
top: 2.0rem; bottom: 2.0rem;
inset-12
inset: 3.0rem;
top-12
top: 3.0rem;
right-12
right: 3.0rem;
bottom-12
bottom: 3.0rem;
left-12
left: 3.0rem;
inset-x-12
left: 3.0rem; right: 3.0rem;
inset-y-12
top: 3.0rem; bottom: 3.0rem;
inset-16
inset: 4.0rem;
top-16
top: 4.0rem;
right-16
right: 4.0rem;
bottom-16
bottom: 4.0rem;
left-16
left: 4.0rem;
inset-x-16
left: 4.0rem; right: 4.0rem;
inset-y-16
top: 4.0rem; bottom: 4.0rem;
inset-20
inset: 5.0rem;
top-20
top: 5.0rem;
right-20
right: 5.0rem;
bottom-20
bottom: 5.0rem;
left-20
left: 5.0rem;
inset-x-20
left: 5.0rem; right: 5.0rem;
inset-y-20
top: 5.0rem; bottom: 5.0rem;
inset-24
inset: 6.0rem;
top-24
top: 6.0rem;
right-24
right: 6.0rem;
bottom-24
bottom: 6.0rem;
left-24
left: 6.0rem;
inset-x-24
left: 6.0rem; right: 6.0rem;
inset-y-24
top: 6.0rem; bottom: 6.0rem;
inset-32
inset: 8.0rem;
top-32
top: 8.0rem;
right-32
right: 8.0rem;
bottom-32
bottom: 8.0rem;
left-32
left: 8.0rem;
inset-x-32
left: 8.0rem; right: 8.0rem;
inset-y-32
top: 8.0rem; bottom: 8.0rem;
inset-40
inset: 10.0rem;
top-40
top: 10.0rem;
right-40
right: 10.0rem;
bottom-40
bottom: 10.0rem;
left-40
left: 10.0rem;
inset-x-40
left: 10.0rem; right: 10.0rem;
inset-y-40
top: 10.0rem; bottom: 10.0rem;
inset-48
inset: 12.0rem;
top-48
top: 12.0rem;
right-48
right: 12.0rem;
bottom-48
bottom: 12.0rem;
left-48
left: 12.0rem;
inset-x-48
left: 12.0rem; right: 12.0rem;
inset-y-48
top: 12.0rem; bottom: 12.0rem;
inset-56
inset: 14.0rem;
top-56
top: 14.0rem;
right-56
right: 14.0rem;
bottom-56
bottom: 14.0rem;
left-56
left: 14.0rem;
inset-x-56
left: 14.0rem; right: 14.0rem;
inset-y-56
top: 14.0rem; bottom: 14.0rem;
inset-64
inset: 16.0rem;
top-64
top: 16.0rem;
right-64
right: 16.0rem;
bottom-64
bottom: 16.0rem;
left-64
left: 16.0rem;
inset-x-64
left: 16.0rem; right: 16.0rem;
inset-y-64
top: 16.0rem; bottom: 16.0rem;
inset-72
inset: 18.0rem;
top-72
top: 18.0rem;
right-72
right: 18.0rem;
bottom-72
bottom: 18.0rem;
left-72
left: 18.0rem;
inset-x-72
left: 18.0rem; right: 18.0rem;
inset-y-72
top: 18.0rem; bottom: 18.0rem;
inset-80
inset: 20.0rem;
top-80
top: 20.0rem;
right-80
right: 20.0rem;
bottom-80
bottom: 20.0rem;
left-80
left: 20.0rem;
inset-x-80
left: 20.0rem; right: 20.0rem;
inset-y-80
top: 20.0rem; bottom: 20.0rem;
inset-96
inset: 24.0rem;
top-96
top: 24.0rem;
right-96
right: 24.0rem;
bottom-96
bottom: 24.0rem;
left-96
left: 24.0rem;
inset-x-96
left: 24.0rem; right: 24.0rem;
inset-y-96
top: 24.0rem; bottom: 24.0rem;
ClassCSS OutputActions
flex-row
flex-direction: row;
flex-row-reverse
flex-direction: row-reverse;
flex-col
flex-direction: column;
flex-col-reverse
flex-direction: column-reverse;
flex-wrap
flex-wrap: wrap;
flex-wrap-reverse
flex-wrap: wrap-reverse;
flex-nowrap
flex-wrap: nowrap;
flex-1
flex: 1 1 0%;
flex-auto
flex: 1 1 auto;
flex-initial
flex: 0 1 auto;
flex-none
flex: none;
growv3: flex-grow
flex-grow: 1;
grow-0v3: flex-grow-0
flex-grow: 0;
shrinkv3: flex-shrink
flex-shrink: 1;
shrink-0v3: flex-shrink-0
flex-shrink: 0;
order-first
order: -9999;
order-last
order: 9999;
order-none
order: 0;
order-1
order: 1;
-order-1
order: -1;
order-2
order: 2;
-order-2
order: -2;
order-3
order: 3;
-order-3
order: -3;
order-4
order: 4;
-order-4
order: -4;
order-5
order: 5;
-order-5
order: -5;
order-6
order: 6;
-order-6
order: -6;
order-7
order: 7;
-order-7
order: -7;
order-8
order: 8;
-order-8
order: -8;
order-9
order: 9;
-order-9
order: -9;
order-10
order: 10;
-order-10
order: -10;
order-11
order: 11;
-order-11
order: -11;
order-12
order: 12;
-order-12
order: -12;
basis-0
flex-basis: 0.0rem;
basis-0.5
flex-basis: 0.125rem;
basis-1
flex-basis: 0.25rem;
basis-1.5
flex-basis: 0.375rem;
basis-2
flex-basis: 0.5rem;
basis-2.5
flex-basis: 0.625rem;
basis-3
flex-basis: 0.75rem;
basis-3.5
flex-basis: 0.875rem;
basis-4
flex-basis: 1.0rem;
basis-5
flex-basis: 1.25rem;
basis-6
flex-basis: 1.5rem;
basis-8
flex-basis: 2.0rem;
basis-10
flex-basis: 2.5rem;
basis-12
flex-basis: 3.0rem;
basis-16
flex-basis: 4.0rem;
basis-20
flex-basis: 5.0rem;
basis-24
flex-basis: 6.0rem;
basis-32
flex-basis: 8.0rem;
basis-40
flex-basis: 10.0rem;
basis-48
flex-basis: 12.0rem;
basis-56
flex-basis: 14.0rem;
basis-64
flex-basis: 16.0rem;
basis-72
flex-basis: 18.0rem;
basis-80
flex-basis: 20.0rem;
basis-96
flex-basis: 24.0rem;
basis-1/2
flex-basis: 1/2;
basis-1/3
flex-basis: 1/3;
basis-2/3
flex-basis: 2/3;
basis-1/4
flex-basis: 1/4;
basis-2/4
flex-basis: 2/4;
basis-3/4
flex-basis: 3/4;
basis-1/5
flex-basis: 1/5;
basis-2/5
flex-basis: 2/5;
basis-3/5
flex-basis: 3/5;
basis-4/5
flex-basis: 4/5;
basis-1/6
flex-basis: 1/6;
basis-2/6
flex-basis: 2/6;
basis-3/6
flex-basis: 3/6;
basis-4/6
flex-basis: 4/6;
basis-5/6
flex-basis: 5/6;
basis-1/12
flex-basis: 1/12;
basis-5/12
flex-basis: 5/12;
basis-7/12
flex-basis: 7/12;
basis-11/12
flex-basis: 11/12;
basis-auto
flex-basis: auto;
basis-full
flex-basis: 100%;

Tailwind CSS v4 rewrote the framework from the ground up. The configuration file is gone, replaced by CSS-first directives like @theme and @source. The color system moved from HSL to OKLCH. New utilities like 3D transforms, container queries, and field sizing landed alongside dozens of renamed and removed classes. If you are upgrading an existing project or starting fresh with v4, having every class, every new feature, and every breaking change in one searchable reference saves you from constantly switching between the official docs and your editor. This cheat sheet covers all of it: the complete utility class reference organized by category, the new CSS-first configuration system, the v3-to-v4 migration differences, and practical examples you can copy directly into your project.

How to Use This Tailwind v4 Cheat Sheet

This cheat sheet is built for speed. Whether you know the class name and want to see its CSS output, or you know what you want to achieve and need to find the right utility, the tool adapts to your workflow. Everything runs inside your browser with zero latency.
1

Search by class name or CSS property

Type any Tailwind utility class like flex, bg-sky-500, or md:grid-cols-3 into the search bar and the cheat sheet instantly filters to show matching results. You can also search by CSS property name like display, background-color, or grid-template-columns. The search works in both directions, so you can go from CSS to Tailwind or Tailwind to CSS depending on what you already know.

2

Browse categories with live preview

The cheat sheet organizes every utility into logical categories: Layout, Flexbox and Grid, Spacing, Sizing, Typography, Backgrounds, Borders, Effects, Filters, Tables, Transitions and Animation, Transforms, Interactivity, SVG, and Accessibility. Click any category to expand it and see every class alongside a live visual preview that shows exactly what that class does. No more guessing what ring-2 looks like versus ring-4.

3

Copy classes with one click

Every class in the cheat sheet has a copy button next to it. Click once and the class name lands on your clipboard, ready to paste into your HTML or JSX. For classes that take arbitrary values like w-[320px] or text-[#1a1a2e], the cheat sheet shows both the standard scale values and the arbitrary value syntax so you know your options.

4

Save your frequently used classes

The Saved tab stores the classes you use most often. Add any class from the reference, and it persists in your browser's local storage. This is useful for teams that share a common design system or for developers who always reach for the same set of spacing, color, and typography classes. Your saved data never leaves your device.

5

Explore v4-specific new features

The New in v4 tab highlights every utility, feature, and syntax change that landed in Tailwind CSS v4. This includes 3D transform utilities like rotate-x-45 and perspective-dramatic, container query utilities like @container and sm:@lg:grid-cols-2, the OKLCH color palette, field-sizing utilities, inset shadow classes, and the CSS-first configuration system using @theme, @source, @utility, and @variant directives. Every new feature includes an example and a link to the relevant section in the official documentation.

What Is New in Tailwind CSS v4: The Complete Breakdown

Tailwind CSS v4 is not an incremental update. It is a fundamental rearchitecture that changes how you configure, write, and think about utility-first CSS. The framework moved from a JavaScript configuration file to CSS-native configuration, replaced the HSL color space with OKLCH for perceptually uniform colors, introduced a new engine built on Rust and Lightning CSS for dramatically faster builds, and added dozens of new utilities that were impossible or impractical in v3. This section covers every major change and what it means for your projects. The most significant shift is the elimination of tailwind.config.js. In v4, all customization happens inside your CSS file using the @theme directive. You define your design tokens, spacing scale, colors, fonts, and breakpoints directly in CSS, which means your configuration lives alongside your styles instead of in a separate JavaScript file. The @source directive tells Tailwind where to scan for class usage, replacing the content array from the config file. The @utility directive lets you define custom utilities as CSS, and @variant lets you create custom variant modifiers. This CSS-first approach means your entire Tailwind setup is expressed in one language, one file, and one mental model. The build engine itself was rewritten in Rust on top of Lightning CSS, delivering build times up to 10x faster than v3. For large projects with thousands of templates, this means sub-second builds instead of multi-second waits. The new engine also produces smaller output because it can detect and remove unused CSS more precisely. Tree-shaking is now handled at the CSS level rather than the template level, which means fewer false positives where used classes get stripped from production builds.

Tailwind v3 vs v4: What Changed, What Moved, What Disappeared

If you are migrating from v3, these are the differences that will affect your day-to-day work. Some classes were renamed, some were removed entirely, and some behaviors changed in ways that might break existing layouts if you are not aware of them.

Configuration moved from JavaScript to CSS

In v3, you customized Tailwind through tailwind.config.js with a content array, theme.extend, and plugins. In v4, all of this happens in your CSS file. Use @theme { } to define design tokens, @source to specify content paths, and @utility to create custom utilities. There is no more tailwind.config.js. If you have an existing config, Tailwind provides a migration tool (npx @tailwindcss/upgrade) that converts your JavaScript config into CSS @theme directives automatically.

Color opacity syntax changed

V3 used separate opacity utilities like bg-opacity-50 alongside color utilities like bg-blue-500. V4 removes the opacity utilities entirely. Instead, you use the slash syntax directly on the color class: bg-blue-500/50 gives you blue-500 at 50% opacity. This applies to text colors (text-red-600/80), border colors (border-gray-300/40), and every other color property. The old bg-opacity-* classes no longer exist.

Ring utilities replaced by shadow utilities

V3 had ring, ring-offset, and ring-opacity utilities that created box-shadow-based outlines. V4 replaces these with the more general shadow-* utilities and the outline-* utilities. If you used ring-2 ring-blue-500 in v3, you can use shadow-[0_0_0_2px_theme(colors.blue.500)] or the new outline utilities in v4. The ring-* classes have been deprecated.

Theme values use CSS variables

V4 exposes every theme value as a CSS custom property. The spacing scale is available as var(--spacing), colors as var(--color-blue-500), and so on. This means you can reference Tailwind theme values in your own CSS, in JavaScript, or in any context where you need a specific token. In v3, accessing theme values required the theme() function in your config or arbitrary values like bg-[theme(colors.blue.500)].

New @variant directive replaces plugins

Custom variants in v3 required writing a JavaScript plugin with addVariant(). In v4, you define variants directly in CSS using @variant. For example, @variant hocus (&:hover, &:focus) creates a hocus: modifier that applies styles on both hover and focus. This is simpler, more readable, and stays within the CSS ecosystem.

Default border color changed

In v3, the default border color was gray-200. In v4, the default is the current text color (currentColor), which matches how CSS borders work natively. If you relied on the gray default, you now need to explicitly add border-gray-200 to your elements.

New arbitrary value syntax

V4 expands the arbitrary value system with a cleaner syntax. Properties that accept CSS custom properties can now use the parenthesized syntax: aspect-(--my-ratio) reads a CSS variable directly, and w-(--sidebar-width) does the same for widths. This is shorter and more readable than the bracket syntax w-[var(--sidebar-width)] used in v3.

Tailwind v4 CSS-First Configuration: @theme, @source, @utility, @variant

The four new CSS directives are the backbone of Tailwind v4 customization. Each one replaces a piece of the old JavaScript configuration system with a CSS-native equivalent that is more intuitive, more composable, and easier to debug.
@themeDefines your design tokens inside CSS. Use @theme { --color-primary: #3b82f6; --font-display: 'Cal Sans', sans-serif; --breakpoint-xs: 475px; } to set colors, fonts, spacing, breakpoints, and any other token. These values automatically become available as Tailwind utilities: bg-primary, font-display, xs:flex, etc. The @theme block replaces theme.extend in your old config file.
@sourceTells Tailwind where to find class usage. Use @source '../src/**/*.{html,tsx,jsx}' to specify content paths. Multiple @source directives are allowed. This replaces the content array from tailwind.config.js. If you omit @source entirely, Tailwind scans all files in your project by default, which works for most setups.
@utilityCreates custom utility classes in CSS. Use @utility card-shadow { box-shadow: 0 4px 6px -1px var(--color-gray-200); } to define a utility named card-shadow that you can use like any other Tailwind class. Custom utilities support modifiers: hover:card-shadow and responsive prefixes work automatically. This replaces the addUtility() plugin API from v3.
@variantDefines custom variant modifiers. Use @variant hocus (&:hover, &:focus) { } to create a hocus: prefix that applies styles on both hover and focus. Variants can reference any CSS selector, making them far more flexible than the v3 plugin system. This replaces the addVariant() plugin API.
@import "tailwindcss"The single line that replaces your entire PostCSS setup. Adding @import 'tailwindcss' to your main CSS file gives you the full framework: base styles, all utility classes, and the v4 engine. No more @tailwind base; @tailwind components; @tailwind utilities; directives. One import, everything included.

Tailwind v4 New Utility Classes Reference

These are the utility classes that are entirely new in v4 and did not exist in v3. Each entry shows the class name pattern, the CSS property it maps to, and a brief description of what it does. Use this table as a quick lookup when you need v4-specific functionality.

3D Transform Utilities (New in v4)

ClassCSS PropertyDescription
rotate-x-*transform: rotateX(*)Rotate element around X axis (3D)
rotate-y-*transform: rotateY(*)Rotate element around Y axis (3D)
rotate-z-*transform: rotateZ(*)Rotate element around Z axis (alias for rotate-*)
scale-x-*transform: scaleX(*)Scale element along X axis
scale-y-*transform: scaleY(*)Scale element along Y axis
scale-z-*transform: scaleZ(*)Scale element along Z axis (3D)
scale-3dtransform: scale3d()Enable 3D scaling context
translate-z-*transform: translateZ(*)Translate element along Z axis (3D)
perspective-*perspective: *Set perspective distance for 3D transforms
perspective-origin-*perspective-origin: *Set vanishing point for 3D perspective
transform-3dtransform-style: preserve-3dEnable 3D transform context on children
transform-flattransform-style: flatFlatten children into 2D plane
backface-visiblebackface-visibility: visibleShow element when facing away
backface-hiddenbackface-visibility: hiddenHide element when facing away

Container Query Utilities (New in v4)

ClassCSS PropertyDescription
@containercontainer-type: inline-sizeDefine a container query context
@container-*container-name: *Name a container for targeted queries
sm:@container@container (min-width: 640px)Container query at small size
md:@container@container (min-width: 768px)Container query at medium size
lg:@container@container (min-width: 1024px)Container query at large size

Other New Utilities in v4

ClassCSS PropertyDescription
field-sizing-contentfield-sizing: contentAuto-size textareas to content
field-sizing-fixedfield-sizing: fixedFixed size form fields (default)
inset-shadow-*box-shadow: inset *Inner shadow utilities
inset-ring-*box-shadow: inset 0 0 0 *Inner ring utilities
text-wrap-prettytext-wrap: prettyPrevent orphans in last line
text-wrap-balancetext-wrap: balanceBalance lines of text evenly
text-wrap-autotext-wrap: autoDefault text wrapping behavior
stroke-w-*stroke-width: *SVG stroke width utility

Real-World Tailwind v4 Code Examples

These examples show v4-specific patterns that leverage new features like 3D transforms, container queries, OKLCH colors, and CSS-first configuration. Each example is copy-ready and demonstrates a practical use case.

3D Card Flip Effect

Combine perspective-*, transform-3d, rotate-y-180, and backface-hidden to create a card that flips when hovered. The parent gets perspective-dramatic to set the 3D viewing distance, and each face uses backface-hidden to hide when facing away. This was impossible with Tailwind v3 utilities alone and required custom CSS.

Container Query Responsive Sidebar

Use @container on a parent element and sm:@lg:flex-row on a child to create a sidebar that switches from stacked to side-by-side based on the parent's width, not the viewport. This is the key advantage of container queries over media queries: the same component adapts to its container, whether it is in a wide dashboard layout or a narrow sidebar panel.

CSS-First Theme Configuration

Replace your entire tailwind.config.js with @theme { --color-brand: oklch(0.7 0.15 250); --font-heading: 'Inter', sans-serif; --radius-btn: 0.5rem; } inside your main CSS file. Now bg-brand, font-heading, and rounded-btn work as native Tailwind utilities. No JavaScript, no plugins, no build step configuration. The theme values are CSS variables that you can also reference in your own styles.

Auto-Sizing Textarea with field-sizing-content

Apply field-sizing-content to a textarea element and it automatically grows to fit its content as the user types. No JavaScript resize observer needed. The textarea shrinks back when text is deleted. This is a native CSS feature that Tailwind v4 exposes as a utility class, solving one of the most common frontend annoyances with a single class.

OKLCH Color Palette with Perceptual Uniformity

V4's default color palette uses OKLCH instead of HSL, which means each shade in a color scale appears equally distant from its neighbors to the human eye. bg-blue-500 and bg-red-500 have the same perceived lightness, making your designs feel more balanced. You can also define custom OKLCH colors in @theme that maintain this uniformity across your entire palette.

Common Mistakes When Using Tailwind v4

Migrating to v4 or starting fresh with it introduces some pitfalls that catch even experienced Tailwind users off guard. These are the errors we see most often, along with the fix for each one.

Using v3 class names that no longer exist

Classes like bg-opacity-50, ring-2, ring-offset-2, placeholder-purple-300, and divide-gray-200 either changed syntax or were removed in v4. Running npx @tailwindcss/upgrade on your project catches most of these automatically, but it misses dynamic class names constructed with string concatenation. Search your codebase for these patterns and update them manually after running the migration tool.

Forgetting to replace tailwind.config.js with @theme

If you delete tailwind.config.js without migrating your customizations into @theme blocks in your CSS file, all your custom colors, fonts, spacing, and breakpoints disappear silently. The upgrade tool handles this conversion, but only if you run it before deleting the config. Always run npx @tailwindcss/upgrade first, verify the output, and then remove the old config file.

Mixing v3 and v4 syntax in the same project

Using @tailwind base/components/utilities directives alongside @import 'tailwindcss' causes conflicts. V4 uses the single import syntax, and the old triple-directive syntax is removed. Choose one approach and stick with it. If you are on v4, use only @import 'tailwindcss' and remove any @tailwind directives from your CSS.

Not updating the content path configuration

V3 used the content array in tailwind.config.js. V4 uses @source directives in CSS or autodetects content paths. If your v4 project is missing styles in production, it is likely because the @source paths do not cover all your template files. Check that your @source patterns match every directory where you use Tailwind classes, including component libraries and node_modules packages.

Expecting default border colors to match v3

V4 changed the default border color from gray-200 to currentColor. This means borders inherit the text color by default, which is how CSS borders work natively but differs from v3. If your design depends on gray borders, add border-gray-200 explicitly to elements that need it.

Best Practices for Working with Tailwind v4

These practices help you get the most out of Tailwind v4, whether you are starting a new project or migrating an existing one. They cover configuration, performance, and team collaboration.

Keep all configuration in one CSS file

V4's CSS-first approach means your entire Tailwind configuration lives in your main CSS file. Resist the temptation to split @theme blocks across multiple files. One CSS file with all @theme, @source, @utility, and @variant directives makes it easy for any team member to find and modify design tokens. If the file gets large, use CSS comments to organize sections by category (colors, spacing, typography, etc.).

Use OKLCH colors for perceptual uniformity

When defining custom colors in @theme, prefer OKLCH values over HEX or RGB. OKLCH produces color scales where each step appears equally different to the human eye, unlike HSL where blue-500 and yellow-500 at the same lightness value look dramatically different in perceived brightness. This makes your design system feel more cohesive and accessible.

Leverage container queries for component-level responsiveness

Container queries let components respond to their own width instead of the viewport width. This means a sidebar card component and a main content card component can share the same code but adapt differently based on their container. Use @container on parent elements and sm:@container, md:@container modifiers on children. This pattern reduces code duplication and makes components truly portable.

Use the slash syntax for color opacity everywhere

The v3 pattern of separate opacity utilities (bg-opacity-50, text-opacity-80) is gone. The v4 slash syntax (bg-blue-500/50, text-gray-900/80) is more concise, more readable, and combines the color and opacity into a single token. Adopt this pattern consistently across your project for cleaner class lists and easier visual scanning.

Run the upgrade tool before manual migration

The npx @tailwindcss/upgrade command handles the most tedious parts of v3-to-v4 migration: converting tailwind.config.js to @theme, updating class names that changed syntax, and replacing deprecated utilities. Run it first, review the changes, and then manually handle edge cases like dynamically constructed class names and third-party component libraries that bundle v3 classes.

Frequently Asked Questions About Tailwind CSS v4

These are the questions developers ask most often when switching to or learning Tailwind v4, based on community forums, GitHub issues, and support channels.