Fill

Utilities for styling the fill of SVG elements.

Default class reference

Class
Properties
fill-currentfill: 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.

Fill - 图1

  1. <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:

  1. // tailwind.config.js
  2. module.exports = {
  3. theme: {
  4. - fill: {
  5. - current: 'currentColor',
  6. - }
  7. + fill: theme => ({
  8. + 'red': theme('colors.red.500'),
  9. + 'green': theme('colors.green.500'),
  10. + 'blue': theme('colors.blue.500'),
  11. + })
  12. }
  13. }

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:

  1. // tailwind.config.js
  2. module.exports = {
  3. variants: {
  4. extend: {
  5. // ...
  6. + fill: ['hover', 'focus'],
  7. }
  8. }
  9. }

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:

  1. // tailwind.config.js
  2. module.exports = {
  3. corePlugins: {
  4. // ...
  5. + fill: false,
  6. }
  7. }

←User Select Stroke→

Edit this page on GitHub