SVG

stroke-width

用於設定 SVG 元素描邊寬度樣式的通用類別。

ClassStyles
stroke-<number>
stroke-width: <number>;
stroke-(length:<custom-property>)
stroke-width: var(<custom-property>);
stroke-[<value>]
stroke-width: <value>;

範例(Examples)

基本範例(Basic example)

使用 stroke-<number> 通用類別(如 stroke-1stroke-2)來設定 SVG 的描邊寬度:

<svg class="stroke-1 ..."></svg><svg class="stroke-2 ..."></svg>

這對於設定像 Heroicons 這樣的圖示集樣式非常有用。

使用自訂值(Using a custom value)

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

<div class="stroke-[1.5] ...">  <!-- ... --></div>

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

<div class="stroke-(length:--my-stroke-width) ...">  <!-- ... --></div>

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

響應式設計(Responsive design)

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

<div class="stroke-1 md:stroke-2 ...">  <!-- ... --></div>

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

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