1. Typography
  2. text-decoration-color

Typography

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(0.971 0.013 17.38) */
decoration-red-100
text-decoration-color: var(--color-red-100); /* oklch(0.936 0.032 17.717) */
decoration-red-200
text-decoration-color: var(--color-red-200); /* oklch(0.885 0.062 18.334) */
decoration-red-300
text-decoration-color: var(--color-red-300); /* oklch(0.808 0.114 19.571) */
decoration-red-400
text-decoration-color: var(--color-red-400); /* oklch(0.704 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 text decoration color based on a completely custom value:

<p class="decoration-[#50d71e] ...">  <!-- ... --></p>

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

<p class="decoration-(--my-color) ...">  <!-- ... --></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 ...">  <!-- ... --></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">  <!-- ... --></p>

Learn more about customizing your theme in the theme documentation.

版权所有 © 2025 Tailwind Labs Inc.·商标政策