Stroke Width

Tailwind CSS version
v1.2.0+

Utilities for styling the stroke width of SVG elements.

Class reference

Class
Properties
.stroke-0stroke-width: 0;
.stroke-1stroke-width: 1;
.stroke-2stroke-width: 2;

Usage

Use the .stroke-{width} utilities to set the stroke width of an SVG.

Useful for styling icon sets like Feather that are drawn entirely with strokes.

<svg class="stroke-current stroke-1 text-green-500 ..."></svg>
<svg class="stroke-current stroke-2 text-green-500 ..."></svg>

Responsive

To control the stroke width of an SVG element at a specific breakpoint, add a {screen}: prefix to any existing width utility. For example, adding the class md:stroke-2 to an element would apply the stroke-2 utility at medium screen sizes and above.

For more information about Tailwind's responsive design features, check out the Responsive Design documentation.

<svg class="stroke-1 sm:stroke-2 md:stroke-1 lg:stroke-0 xl:stroke-1 ...">
  <!-- ... -->
</svg>

Customizing

Control which stroke-width utilities Tailwind generates by customizing the theme.strokeWidth section in your tailwind.config.js file:

  // tailwind.config.js
  module.exports = {
    theme: {
      extend: {
        strokeWidth: {
+         '3': '3',
+         '4': '4',
        }
      }
    }
  }

Learn more about customizing the default theme in the theme customization documentation.

Responsive and pseudo-class variants

By default, only responsive variants are generated for stroke-width utilities.

You can control which variants are generated for the stroke-width utilities by modifying the strokeWidth 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: {
      // ...
-     strokeWidth: ['responsive'],
+     strokeWidth: ['responsive', 'hover', 'focus'],
    }
  }

Disabling

If you don't plan to use the stroke-width utilities in your project, you can disable them entirely by setting the strokeWidth property to false in the corePlugins section of your config file:

  // tailwind.config.js
  module.exports = {
    corePlugins: {
      // ...
+     strokeWidth: false,
    }
  }

Tailwind UI is now in early access!