Fill
Utilities for styling the fill of SVG elements.
Default class reference
Class | Properties |
---|---|
fill-current | fill: currentColor; |
Usage
Use fill-current
to set the fill color of an SVG to the current text color. This makes it easy to set an element’s fill color by combining this class with an existing text color utility.
Useful for styling icon sets like Zondicons that are drawn entirely with fills.
<svg class="fill-current text-green-600 ..."></svg>
Customizing
Control which fill utilities Tailwind generates by customizing the theme.fill
section of your tailwind.config.js
file:
// tailwind.config.js
module.exports = {
theme: {
- fill: {
- current: 'currentColor',
- }
+ fill: theme => ({
+ 'red': theme('colors.red.500'),
+ 'green': theme('colors.green.500'),
+ 'blue': theme('colors.blue.500'),
+ })
}
}
Variants
By default, only responsive variants are generated for fill utilities.
You can control which variants are generated for the fill utilities by modifying the fill
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: {
extend: {
// ...
+ fill: ['hover', 'focus'],
}
}
}
Disabling
If you don’t plan to use the fill utilities in your project, you can disable them entirely by setting the fill
property to false
in the corePlugins
section of your config file:
// tailwind.config.js
module.exports = {
corePlugins: {
// ...
+ fill: false,
}
}