Last updated: 12 May 2024

Tailwind Background Clip

The bg-{clip} utility class in Tailwind CSS allows you to control the clipping behavior of background images applied to elements.


Tailwind Background Clip

The bg-{clip} utility class in Tailwind CSS allows you to control the clipping behavior of background images applied to elements. With Tailwind's bg-{clip} class, you can easily adjust how the background image is clipped to the element's box model.

Applying Tailwind Background Clip

To apply a specific tailwind background clip behavior to an element, you can use the bg-{clip} utility class, where {clip} represents the desired background clip. Here are some common values you can use:

  • bg-clip-border: The background image is clipped to the border box.
  • bg-clip-padding: The background image is clipped to the padding box.
  • bg-clip-content: The background image is clipped to the content box. Here's an example:
html
<div class="bg-clip-padding">
This element has a background image that is clipped to the border.
</div>
<div class="bg-clip-padding">
This element has a background image that is clipped to the padding box.
</div>
<div class="bg-clip-padding">
This element has a background image that is clipped to the content.
</div>

Preview

This element has a background image that is clipped to the border.

This element has a background image that is clipped to the padding box.

This element has a background image that is clipped to the content.

Responsive Tailwind Background Clip

Tailwind CSS allows you to apply background clip classes responsively at different breakpoints. To use responsive tailwind background clip classes, you can append the breakpoint prefix to the utility class. For example, md:bg-clip-content sets the tailwind background clip to the content box starting from the medium breakpoint and above.

html
<div class="bg-clip-border md:bg-clip-content">
This element has a background image that is clipped to the border box by
default, but starting from the medium breakpoint and above, it changes to be
clipped to the content box.
</div>

In the above example, the background clip of the <div> element is set to the border box by default (bg-clip-border), but starting from the medium breakpoint and above, it changes to be clipped to the content box (md:bg-clip-content).

Tailwind Background Clip ClassN Table

ClassProperties
bg-clip-borderbackground-clip: border-box;
bg-clip-paddingbackground-clip: padding-box;
bg-clip-contentbackground-clip: content-box;
bg-clip-text background-clip: text;

Windframe Tailwind blocks

Timeline

Windframe is a drag and drop builder for rapidly building tailwind css websites and UIs

Start building stunning tailwind UIs! 

Build from scratch or select prebuilt tailwind templates