bg-clip-content: Tailwind CSS background attachement class

The bg-clip-content class ensures that the background only applies to the content of the element, not the padding or border.


bg-clip-content (Background Clip Content)

The bg-clip-content class ensures that the background only applies to the content of the element, not the padding or border.

Example Code

html
<div class="bg-blue-500 bg-clip-content text-white p-4 border border-gray-400">
Background clipped to content
</div>

Preview

Background clipped to content

How to Use

Add the bg-clip-content class directly to your HTML element:

html
<div class="bg-clip-content">
<!-- Your content here -->
</div>

Responsive Usage

Use Tailwind's responsive prefixes to apply bg-clip-content at specific breakpoints:

html
<div class="sm:bg-clip-content md:bg-clip-content lg:bg-clip-content">
Responsive element
</div>
  • sm:bg-clip-content — applies from 640px and up
  • md:bg-clip-content — applies from 768px and up
  • lg:bg-clip-content — applies from 1024px and up

Customization

You can extend or override this utility in your tailwind.config.js. See the Tailwind CSS documentation for details on customizing your theme.

Windframe is an AI visual editor for rapidly building stunning web UIs & websites

Start building stunning web UIs & websites!

Build from scratch or select prebuilt tailwind templates