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(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) */

範例(Examples)

基本範例(Basic example)

使用 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>

變更不透明度(Changing the opacity)

使用顏色不透明度修飾符來控制元素的文字裝飾顏色不透明度:

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>

使用自訂值(Using a custom value)

使用 decoration-[<value>] 語法,根據完全自訂的值來設定 text decoration color

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

對於 CSS 變數,你也可以使用 decoration-(<custom-property>) 語法:

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

這只是 decoration-[var(<custom-property>)] 的簡寫形式,會自動為你加上 var() 函式。

在 hover 時套用(Applying on hover)

text-decoration-color 通用類別前面加上像 hover:* 這樣的變體,讓該通用類別只在該狀態下套用:

將滑鼠移到文字上以查看預期行為

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>

變體文件中了解更多關於使用變體的資訊。

響應式設計(Responsive design)

text-decoration-color 通用類別前面加上像 md: 這樣的中斷點變體,讓該通用類別只在中型螢幕尺寸及以上時套用:

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

變體文件中了解更多關於使用變體的資訊。

自訂主題(Customizing your theme)

使用 --color-* 主題變數來自訂專案中的 color 通用類別:

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

現在可以在標記中使用 decoration-regal-blue 通用類別:

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

主題文件中了解更多關於自訂主題的資訊。

Copyright © 2026 Tailwind Labs Inc.·商標政策(Brand)