Stroke
Utilities for styling the stroke of SVG elements.
Class reference
Class | Properties |
---|---|
.stroke-current | stroke: currentColor; |
Usage
Use .stroke-current
to set the stroke color of an SVG to the current text color. This makes it easy to set an element’s stroke color by combining this class with an existing text color utility.
Useful for styling icon sets like Feather that are drawn entirely with strokes.
<svg class="stroke-current text-purple-500 inline-block h-12 w-12" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="8" cy="21" r="2" />
<circle cx="20" cy="21" r="2" />
<path d="M5.67 6H23l-1.68 8.39a2 2 0 0 1-2 1.61H8.75a2 2 0 0 1-2-1.74L5.23 2.74A2 2 0 0 0 3.25 1H1" />
</svg>
Customizing
Control which stroke utilities Tailwind generates by customizing the theme.stroke
section in your tailwind.config.js
file:
// tailwind.config.js
module.exports = {
theme: {
- stroke: {
- current: 'currentColor',
- }
+ stroke: theme => ({
+ 'red': theme('colors.red.500'),
+ 'green': theme('colors.green.500'),
+ 'blue': theme('colors.blue.500'),
+ })
}
}
Responsive and pseudo-class variants
By default, only responsive variants are generated for stroke utilities.
You can control which variants are generated for the stroke utilities by modifying the stroke
property in the variants
section of your tailwind.config.js
file.
For example, this config will also generate hover and focus variants:
// tailwind.config.js
module.exports = {
variants: {
// ...
- stroke: ['responsive'],
+ stroke: ['responsive', 'hover', 'focus'],
}
}
Disabling
If you don’t plan to use the stroke utilities in your project, you can disable them entirely by setting the stroke
property to false
in the corePlugins
section of your config file:
// tailwind.config.js
module.exports = {
corePlugins: {
// ...
+ stroke: false,
}
}