1. 文字排版
  2. text-decoration-color

文字排版

text-decoration-color

用於控制文字裝飾顏色的工具。

類別樣式
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) */

Examples (範例)

Basic example (基本範例)

Use utilities like decoration-sky-500 and decoration-pink-500 to change the text decoration color of an element (使用像 decoration-sky-500decoration-pink-500 這樣的工具來更改元素的 文字裝飾 顏色)

I’m Derek, an astro-engineer based in Tattooine. I like to build X-Wings at (我是 Derek,一位在塔圖因星的太空工程師。我喜歡在以下地方建造 X 翼戰機:) 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 (更改不透明度)

Use the color opacity modifier to control the text decoration color opacity of an element (使用顏色不透明度修飾符來控制元素文字裝飾顏色的不透明度)

I’m Derek, an astro-engineer based in Tattooine. I like to build X-Wings at (我是 Derek,一位在塔圖因星的太空工程師。我喜歡在以下地方建造 X 翼戰機:) 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 (使用自定義值)

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 (對於 CSS 變數,您也可以使用) 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. (它會自動為您新增 var() 函數。)

Applying on hover (套用於滑鼠懸停時)

Prefix (使用前綴)a (一個) text-decoration-color utility with a variant like (text-decoration-color 工具,並搭配像這樣的變體:) hover:* to only apply the utility in that state (hover:* 以僅在該狀態下套用該工具)

Hover over the text to see the expected behavior (將滑鼠懸停在文字上以查看預期行為)

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 (text-decoration-color 工具) with a breakpoint variant like md: to only apply the utility at (使用像 md: 這樣的斷點變體,以僅在以下情況下套用該工具:)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. (在 變體說明文件 中了解有關使用變體的更多資訊。)

Customizing your theme (自定義您的主題)

Use the --color-* theme variables to customize the (使用 --color-* 主題變數來自定義)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 (主題說明文件).

Copyright © 2025 Tailwind Labs Inc.·Trademark Policy (商標政策)