Layout

Utilities for controlling the overall layout and positioning of elements on your page. These foundational utilities help establish the structural framework of your design and control how elements are displayed, positioned, and respond to different screen sizes.

17 utilitieslayout
Official Documentation

Container

The container utility creates a responsive, centered wrapper with max-width constraints that align with Tailwind's breakpoints. It's the foundation for most layouts, ensuring content doesn't stretch too wide on large screens while maximizing available space on smaller devices. Note that in Tailwind v4, the container doesn't add padding by default—combine with px-{size} utilities for padding.

<div class="container mx-auto px-4">Your content here</div>
1 variant3 examples
smmdlg+2

Box Decoration Break

Controls how element decorations (like background, border, shadow, etc.) behave when the element breaks across multiple lines or columns. This is particularly useful for styling inline elements that may wrap, such as highlighted text or links. In Tailwind v4, this utility helps ensure consistent styling across fragmented content.

<span class="box-decoration-slice bg-gradient-to-r from-blue-400 to-purple-500 text-white px-2"> This text might wrap across multiple lines with the gradient sliced at each line break. </span>
1 variant3 examples
sliceclone

Box Sizing

Determines how the total width and height of an element is calculated. This fundamental layout utility controls whether padding and border are included in the element's dimensions or added to them. Understanding box-sizing is crucial for creating predictable layouts, especially when working with percentage-based widths.

<div class="box-border w-64 p-4 border-4 border-blue-500 bg-blue-100"> This has a total width of 64px (including padding and border). </div>
1 variant3 examples
bordercontent

Display

Controls how an element is rendered in the document flow. The display property is one of the most important CSS properties for controlling layout and behavior. It determines if an element generates a block or inline box, or a different type of formatting context like flex, grid, or none (hidden). In Tailwind v4, all display utilities benefit from improved compatibility with OKLCH colors and other modern CSS features.

<div class="block">Block element takes full width</div> <span class="inline">Inline element</span> <span class="inline">takes only needed width</span>
1 variant3 examples
blockinline-blockinline+11

Aspect Ratio

Sets the preferred aspect ratio for an element, which will be maintained as the element resizes. This is extremely useful for responsive design, particularly with images, videos, and other media to prevent layout shifts during page load. In Tailwind v4, the aspect-ratio utility has enhanced browser support and performance.

<div class="aspect-square bg-blue-200 w-full max-w-md"> This div will always be perfectly square. </div>
1 variant4 examples
autosquarevideo+1

Columns

Creates multi-column text layouts, similar to newspaper or magazine columns. This allows long blocks of text to flow naturally across multiple columns, improving readability on larger screens. In Tailwind v4, columns utilities have better support across browsers and work well with other modern CSS features.

<div class="columns-2 gap-8"> <p>This is the first paragraph of text that will flow across multiple columns.</p> <p>This is another paragraph that continues the text flow. The text automatically balances across the columns.</p> <p>Here's even more text to demonstrate how content flows from one column to the next, similar to a newspaper layout.</p> </div>
1 variant3 examples
123+10

Break After

Controls how page, column, or region breaks should behave after an element. This is especially useful for print layouts and multi-column content where you need to control where breaks occur. In Tailwind v4, break utilities have improved support across browsers and printing contexts.

<h2 class="break-after-page">Chapter Title</h2> <p>This content will start on a new page when printed.</p>
1 variant3 examples
autoavoidalways+5

Break Before

Controls how page, column, or region breaks should behave before an element. Similar to break-after but affects the space before the element. This provides precise control for print layouts and multi-column content, ensuring content flows naturally across pages and columns.

<h2 class="break-before-page">New Chapter</h2> <p>This heading and all content below it will start on a new page when printed.</p>
1 variant3 examples
autoavoidalways+5

Break Inside

Controls how page, column, or region breaks should behave inside an element. This prevents elements from being split across pages, columns, or regions, which is essential for maintaining the integrity of content blocks like figures, tables, or cards in multi-column layouts and print contexts.

<div class="columns-2"> <figure class="break-inside-avoid mb-4"> <div class="bg-gray-200 aspect-video mb-2"></div> <figcaption class="text-sm text-gray-600">This figure won't be split across columns</figcaption> </figure> <p>Regular paragraph text that can flow naturally between columns...</p> </div>
1 variant3 examples
autoavoidavoid-page+2

Object Fit

Controls how replaced elements like images and videos should be resized and positioned within their containers. This is crucial for responsive design, allowing media to adapt beautifully to different container dimensions without distortion. In Tailwind v4, object-fit utilities work seamlessly with aspect-ratio and other modern layout features.

<div class="w-full h-64 bg-gray-200"> <img class="w-full h-full object-cover" src="example.jpg" alt="Cover example"> </div>
1 variant4 examples
containcoverfill+2

Object Position

Controls the positioning of replaced elements like images and videos within their containing box when using object-fit. This allows you to focus on specific parts of media that should remain visible when cropped. In Tailwind v4, object-position works fluidly with other modern layout utilities and supports logical properties for better RTL handling.

<div class="w-full h-64 bg-gray-200"> <img class="w-full h-full object-cover object-center" src="example.jpg" alt="Centered image"> </div>
1 variant4 examples
bottomcenterleft+6

Overflow

Controls what happens to content that extends beyond its container's boundaries. This is essential for managing how scrolling behaves, whether content should be clipped, or if scrollbars should appear. In Tailwind v4, overflow utilities have improved handling with modern scrolling behaviors and are fully compatible with other layout utilities.

<div class="overflow-hidden h-32 w-full bg-gray-100 rounded"> <p class="p-4">This content is clipped if it overflows the container height...</p> <p class="p-4">Additional content that extends beyond the visible area will be hidden.</p> <p class="p-4">More content to demonstrate overflow.</p> </div>
2 variants4 examples
autohiddenclip+2

Overscroll Behavior

Controls what happens when a user scrolls beyond the boundaries of a scrolling area. This prevents scroll chaining, where reaching the end of a scrollable element causes the parent container or page to scroll. In Tailwind v4, overscroll utilities provide improved handling of nested scrollable areas for a more polished user experience.

<div class="h-screen overflow-auto overscroll-contain"> <!-- Long scrollable content --> <div class="h-[200vh] bg-gradient-to-b from-blue-100 to-blue-500 p-6"> <h2 class="text-xl font-bold">Contained Overscroll Example</h2> <p>Scroll to the bottom - notice that when you reach the end, the page behind doesn't scroll (no bounce/scroll chaining).</p> </div> </div>
2 variants3 examples
autocontainnone

Position

Determines how an element is positioned in the document flow. This fundamental layout utility influences how elements are stacked, how they interact with other elements, and how they respond to scrolling. In Tailwind v4, position utilities are enhanced with better interoperability with other layout utilities like Grid and Flexbox.

<div class="relative bg-gray-200 p-8 h-32"> <div class="absolute top-0 right-0 bg-blue-500 text-white p-2">Absolute to parent</div> <p>This is the relative parent container.</p> </div>
1 variant4 examples
staticrelativeabsolute+2

Top / Right / Bottom / Left

Controls the placement of positioned elements (absolute, fixed, or sticky) by setting the distance from each edge of their containing box. These utilities are used with positioned elements to precisely control their location. In Tailwind v4, these utilities support logical properties for better RTL language support and have improved integration with layout containment.

<div class="relative h-32 w-full bg-gray-200"> <div class="absolute inset-0 bg-blue-200 bg-opacity-50">Full overlay (inset-0)</div> </div>
2 variants4 examples
insetinset-xinset-y+6

Visibility

Controls whether an element is visually perceivable without affecting its layout. Unlike display:none (which removes the element from the flow), visibility: hidden makes an element invisible while still occupying space. In Tailwind v4, visibility utilities have improved interaction with animation and transition utilities for more sophisticated UI effects.

<div class="space-y-4"> <div class="p-4 bg-blue-100 rounded">Visible element</div> <div class="invisible p-4 bg-red-100 rounded">Invisible element (still takes up space)</div> <div class="p-4 bg-green-100 rounded">Another visible element</div> </div>
1 variant4 examples
visibleinvisiblecollapse

Z-Index

Controls the stacking order of positioned elements (those with a position value other than static). Higher z-index values appear on top of elements with lower values. This is vital for creating layered interfaces like modals, tooltips, and sticky headers. In Tailwind v4, z-index utilities have better integration with stacking contexts created by modern CSS properties.

<div class="relative h-32 w-full"> <div class="absolute inset-0 bg-blue-200 z-0">Background layer (z-0)</div> <div class="absolute inset-y-0 left-1/4 right-1/4 bg-blue-400 z-10">Middle layer (z-10)</div> <div class="absolute inset-y-0 left-1/3 right-1/3 flex items-center justify-center bg-blue-600 text-white z-20">Top layer (z-20)</div> </div>
1 variant4 examples
01020+9