Layout

Box Decoration Break

Utilities for controlling how element fragments should be rendered across multiple lines, columns, or pages.

Quick reference

Class
Properties
box-decoration-clonebox-decoration-break: clone;
box-decoration-slicebox-decoration-break: slice;

Basic usage

Setting the box decoration break

Use the box-decoration-slice and box-decoration-clone utilities to control whether properties like background, border, border-image, box-shadow, clip-page, margin, and padding should be rendered as if the element were one continuous fragment, or distinct blocks.

Box Decoration Break - 图1

  1. <span class="box-decoration-slice bg-gradient-to-r from-indigo-600 to-pink-500 text-white px-2 ...">
  2. Hello<br />
  3. World
  4. </span>
  5. <span class="box-decoration-clone bg-gradient-to-r from-indigo-600 to-pink-500 text-white px-2 ...">
  6. Hello<br />
  7. World
  8. </span>

Applying conditionally

Hover, focus, and other states

Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:box-decoration-slice to only apply the box-decoration-slice utility on hover.

  1. <div class="box-decoration-clone hover:box-decoration-slice">
  2. <!-- ... -->
  3. </div>

For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.

Breakpoints and media queries

You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:box-decoration-slice to apply the box-decoration-slice utility at only medium screen sizes and above.

  1. <div class="box-decoration-clone md:box-decoration-slice">
  2. <!-- ... -->
  3. </div>

To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.