tailwind-css
  1. tailwind-css-stroke

Tailwind CSS Stroke

The Tailwind CSS Stroke utility is used to add a stroke around the given element. The stroke can be customized using various Tailwind classes.

Syntax

To apply a stroke around a given element, use the following syntax:

<div class="stroke-{size} stroke-{color} stroke-{opacity} [stroke-{offset}]">
  ...
</div>
  • {size}: The stroke width. It can be a value between 1 to 4.
  • {color}: The color of the stroke. It can be any valid Tailwind color.
  • {opacity}: The opacity of the stroke. It can be a value between 0 to 100.
  • {offset}: The offset of the stroke from the element. It can be a value between 1 to 4. (Optional)

Example

<div class="stroke-2 stroke-gray-700 stroke-opacity-50">
  This element has a gray stroke with 50% opacity and a stroke width of 2.
</div>

Output

Tailwind CSS Stroke Example Output

Explanation

The above example applies a gray stroke around the given element using the stroke-2, stroke-gray-700, and stroke-opacity-50 classes. The stroke-2 class sets the stroke width to 2, stroke-gray-700 sets the stroke color to gray-700, and stroke-opacity-50 sets the opacity of the stroke to 50%.

Use

Use the stroke utility to add a stroke around any element such as text, images, or buttons.

Important Points

  • The stroke utility can be combined with other Tailwind utilities such as rounded to create custom shapes.
  • The stroke utility can also be used in combination with the group-hover or hover utility to create interactive elements that change on hover.

Summary

The Tailwind CSS Stroke utility is used to add a stroke around the element. It provides flexibility in terms of customization with stroke width, color, and opacity. The stroke utility can be used in combination with other Tailwind utilities to create custom shapes or interactive elements that change on hover.

Published on: