
SVG
用于设置 SVG 元素描边宽度的工具。
使用 stroke-* 工具来设置 SVG 的描边宽度。
🌐 Use the stroke-* utilities to set the stroke width of an SVG.
<svg class="stroke-1 ..."></svg>
<svg class="stroke-2 ..."></svg>
这对于像 Heroicons 这样的图标集的样式设置非常有用。
🌐 This can be useful for styling icon sets like Heroicons.
Tailwind 允许你使用变体修饰符在不同状态下有条件地应用工具类。例如,使用hover:stroke-2 仅在 hover 时应用 stroke-2 工具。
<svg class="stroke-1 hover:stroke-2">
<!-- ... -->
</svg>
有关所有可用状态修饰符的完整列表,请查看悬停、聚焦、以及其他状态 文档。
你还可以使用变体修饰符来定位媒体查询,例如响应式断点、暗黑模式、首选减少运动等。例如,使用 md:stroke-2 仅在中等屏幕尺寸及以上时应用 stroke-2 工具。
<svg class="stroke-1 md:stroke-2">
<!-- ... -->
</svg>
要了解更多信息,请查看有关 响应式设计、暗黑模式、以及 其他媒体查询修饰符 的文档。
默认情况下,Tailwind 提供三种 stroke-width 工具。你可以通过编辑 Tailwind 配置中的 theme.strokeWidth 部分来更改、添加或删除这些工具。
🌐 By default, Tailwind provides three stroke-width utilities. You change, add, or remove these by editing the theme.strokeWidth section of your Tailwind config.
module.exports = {
theme: {
extend: {
strokeWidth: {
'2': '2px',
}
}
}
}
在主题自定义文档中了解有关自定义默认主题的更多信息。
🌐 Learn more about customizing the default theme in the theme customization documentation.
如果你需要使用一次性的 stroke-width 值,而该值没有必要包含在你的主题中,请使用方括号动态生成属性,使用任意值。
<svg class="stroke-[2px]">
<!-- ... -->
</svg>
在 任意值 文档中了解有关任意值支持的更多信息。