SVG
Utilities for styling the stroke width of SVG elements.
Use the stroke-{width}
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 includes stroke-width
utilities for creating basic grids with up to 6 equal width rows. You can customize these values by editing theme.strokeWidth
or theme.extend.strokeWidth
in your tailwind.config.js
file.
You have direct access to the stroke-width
CSS property here so you can make your custom rows values as generic or as complicated and site-specific as you like.
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.