Backgrounds

background-clip

Utilities for controlling the bounding box of an element's background.

ClassStyles
bg-clip-border
background-clip: border-box;
bg-clip-padding
background-clip: padding-box;
bg-clip-content
background-clip: content-box;
bg-clip-text
background-clip: text;

Examples

Basic example

Use the bg-clip-border, bg-clip-padding, and bg-clip-content utilities to control the bounding box of an element's background:

bg-clip-border

bg-clip-padding

bg-clip-content

<div class="border-4 bg-indigo-500 bg-clip-border p-3"></div><div class="border-4 bg-indigo-500 bg-clip-padding p-3"></div><div class="border-4 bg-indigo-500 bg-clip-content p-3"></div>

Cropping to text

Use the bg-clip-text utility to crop an element's background to match the shape of the text:

Hello world

<p class="bg-gradient-to-r from-pink-500 to-violet-500 bg-clip-text text-5xl font-extrabold text-transparent ...">  Hello world</p>

Responsive design

Prefix a background-clip utility with a breakpoint variant like md: to only apply the utility at medium screen sizes and above:

<div class="bg-clip-border md:bg-clip-padding ...">  <!-- ... --></div>

Learn more about using variants in the variants documentation.

Copyright © 2025 Tailwind Labs Inc.·Trademark Policy

Tailwind CSS 中文网(本网站)的目标是为中文开发者提供准确、及时的 Tailwind CSS 中文文档

Tailwind CSS 中文文档由本网站维护人员共同翻译,采用 MIT 开源协议发布

本网站与 tailwindcss.com 及 Tailwind Labs Inc. 并无从属关系

Tailwind 商标由 Tailwind Labs Inc. 所有

京ICP备15031610号-8