Quick reference

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

Basic usage

Setting the stroke width

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.


Applying conditionally

Hover, focus, and other states

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.

Breakpoints and media queries

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.


Using custom values

Customizing your theme

By default, Tailwind provides three stroke-width utilities. You change, add, or remove these by editing the theme.strokeWidth section of your Tailwind config.

tailwind.config.js
module.exports = {
  theme: {
    extend: {
      strokeWidth: {
        '2': '2px',
      }
    }
  }
}

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

Arbitrary values

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.