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-textbackground-clip: text;

Windframe Tailwind blocks

Timeline

Build modern projects using Bootstrap 5 and Contrast

Trying to create components and pages for a web app or website from scratch while maintaining a modern User interface can be very tedious. This is why we created Contrast, to help drastically reduce the amount of time we spend doing that. so we can focus on building some other aspects of the project.

Contrast Bootstrap PRO consists of a Premium UI Kit Library featuring over 10000+ component variants. Which even comes bundled together with its own admin template comprising of 5 admin dashboards and 23+ additional admin and multipurpose pages for building almost any type of website or web app.
See a demo and learn more about Contrast Bootstrap Pro by clicking here.

ad-banner