Box Decoration Break

Tailwind CSS version

v2.1+

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

Default class reference

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

Usage

Use the decoration-slice and 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="decoration-clone bg-gradient-to-b from-yellow-400 to-red-500 text-transparent ...">
  2. Hello<br>
  3. World
  4. </span>

Responsive

To control the box-decoration-break property at a specific breakpoint, add a {screen}: prefix to any existing box-decoration-break utility. For example, use md:decoration-slice to apply the decoration-slice utility at only medium screen sizes and above.

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

For more information about Tailwind’s responsive design features, check out the Responsive Design documentation.

Customizing

Variants

By default, only responsive variants are generated for box-decoration-break utilities.

You can control which variants are generated for the box-decoration-break utilities by modifying the boxDecorationBreak property in the variants section of your tailwind.config.js file.

For example, this config will also generate hover and focus variants:

  1. // tailwind.config.js
  2. module.exports = {
  3. variants: {
  4. extend: {
  5. // ...
  6. + boxDecorationBreak: ['hover', 'focus'],
  7. }
  8. }
  9. }

Disabling

If you don’t plan to use the box-decoration-break utilities in your project, you can disable them entirely by setting the boxDecorationBreak property to false in the corePlugins section of your config file:

  1. // tailwind.config.js
  2. module.exports = {
  3. corePlugins: {
  4. // ...
  5. + boxDecorationBreak: false,
  6. }
  7. }

←Container Box Sizing→

Edit this page on GitHub