SVG
Utilities for styling the stroke width of SVG elements.
Use the stroke-*
utilities to set the stroke width of an SVG.
<svg class="stroke-1 ..."></svg>
<svg class="stroke-2 ..."></svg>
This can be useful for styling icon sets like Heroicons.
Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:stroke-2
to only apply the stroke-2
utility on hover.
<svg class="stroke-1 hover:stroke-2">
<!-- ... -->
</svg>
For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.
You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:stroke-2
to apply the stroke-2
utility at only medium screen sizes and above.
<svg class="stroke-1 md:stroke-2">
<!-- ... -->
</svg>
To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.
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.
If you need to use a one-off stroke-width
value that doesn’t make sense to include in your theme, use square brackets to generate a property on the fly using any arbitrary value.
<svg class="stroke-[2px]">
<!-- ... -->
</svg>
Learn more about arbitrary value support in the arbitrary values documentation.