1. 字体
  2. text-decoration-color

字体

文本装饰颜色

用于控制文本装饰线颜色的工具类。

ClassStyles
decoration-inherit
text-decoration-color: inherit;
decoration-current
text-decoration-color: currentColor;
decoration-transparent
text-decoration-color: transparent;
decoration-black
text-decoration-color: var(--color-black); /* #000 */
decoration-white
text-decoration-color: var(--color-white); /* #fff */
decoration-red-50
text-decoration-color: var(--color-red-50); /* oklch(97.1% 0.013 17.38) */
decoration-red-100
text-decoration-color: var(--color-red-100); /* oklch(93.6% 0.032 17.717) */
decoration-red-200
text-decoration-color: var(--color-red-200); /* oklch(88.5% 0.062 18.334) */
decoration-red-300
text-decoration-color: var(--color-red-300); /* oklch(80.8% 0.114 19.571) */
decoration-red-400
text-decoration-color: var(--color-red-400); /* oklch(70.4% 0.191 22.216) */

示例

基础示例

使用 decoration-sky-500decoration-pink-500 等工具类来更改元素的文本装饰线颜色:

I'm Derek, an astro-engineer based in Tattooine. I like to build X-Wings at My Company, Inc. Outside of work, I like to watch pod-racing and have light-saber fights.

<p>  I'm Derek, an astro-engineer based in Tattooine. I like to build X-Wings  at <a class="underline decoration-sky-500">My Company, Inc</a>. Outside  of work, I like to <a class="underline decoration-pink-500">watch pod-racing</a>  and have <a class="underline decoration-indigo-500">light-saber</a> fights.</p>

更改不透明度

使用颜色不透明度修饰符来控制元素文本装饰线的颜色不透明度:

I'm Derek, an astro-engineer based in Tattooine. I like to build X-Wings at My Company, Inc. Outside of work, I like to watch pod-racing and have light-saber fights.

<p>  I'm Derek, an astro-engineer based in Tattooine. I like to build X-Wings  at <a class="underline decoration-sky-500/30">My Company, Inc</a>. Outside  of work, I like to <a class="underline decoration-pink-500/30">watch pod-racing</a>  and have <a class="underline decoration-indigo-500/30">light-saber</a> fights.</p>

使用自定义值

Use the decoration-[<value>] syntax to set the 文本装饰颜色 based on a completely custom value:

<p class="decoration-[#50d71e] ...">  Lorem ipsum dolor sit amet...</p>

For CSS variables, you can also use the decoration-(<custom-property>) syntax:

<p class="decoration-(--my-color) ...">  Lorem ipsum dolor sit amet...</p>

This is just a shorthand for decoration-[var(<custom-property>)] that adds the var() function for you automatically.

悬停时应用

Prefix a text-decoration-color utility with a variant like hover:* to only apply the utility in that state:

将鼠标悬停在文本上以查看预期效果

The quick brown fox jumps over the lazy dog.
<p>The <a href="..." class="underline hover:decoration-pink-500 ...">quick brown fox</a> jumps over the lazy dog.</p>

Learn more about using variants in the variants documentation.

响应式设计

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

<p class="underline decoration-sky-600 md:decoration-blue-400 ...">  Lorem ipsum dolor sit amet...</p>

Learn more about using variants in the variants documentation.

自定义主题

Use the --color-* theme variables to customize the color utilities in your project:

@theme {  --color-regal-blue: #243c5a; }

Now the decoration-regal-blue utility can be used in your markup:

<p class="decoration-regal-blue">  Lorem ipsum dolor sit amet...</p>

Learn more about customizing your theme in the theme documentation.

Copyright © 2025 Tailwind Labs Inc.·Trademark Policy