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.
Layout1 variant3 examples
Basic usage:
<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>
Examples
<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>
<span class="box-decoration-clone bg-gradient-to-r from-blue-400 to-purple-500 text-white px-2">
This text will have the complete gradient applied to each line when it wraps, making each line look like a complete element.
</span>
<!-- Real-world example: Highlighted text that spans multiple lines -->
<p class="text-lg leading-relaxed">
Regular text with
<mark class="box-decoration-clone bg-yellow-200 px-1">
some highlighted content that might wrap across multiple lines while maintaining consistent highlighting
</mark>
and then continue with regular text.
</p>
Live Preview
Try the Box Decoration Break utility with different values
Variants
slice: breaks decorations at line breaks (default), clone: duplicates decorations on each line segment to make each piece look like a complete element
sliceclone
Tips & Reference
Related Functions
ContainerThe container utility creates a responsive, centered wrapper...
Box SizingDetermines how the total width and height of an element is c...
DisplayControls how an element is rendered in the document flow. Th...
Aspect RatioSets the preferred aspect ratio for an element, which will b...
ColumnsCreates multi-column text layouts, similar to newspaper or m...
View all Layout utilities