Quick Guide To Tailwind Stroke Width

This article will provide you with an in-depth analysis of Tailwind stroke width classes with examples.

Typically, stroke width is used in combination with SVG images (Scalable Vector Graphics).

Tailwind Stroke Width

Stroke width is used to define the thickness of lines in SVG images, and can be adjusted through CSS properties such as stroke-width.

Using Tailwind, stroke width is a utility class that specifies the width of an SVG stroke.



Tailwind Stroke Width Classes

Tailwind provides a set of classes for stroke width that range from 0 to 2.

The classes are named using the stroke prefix, followed by a number that represents the thickness of an element.

To implement stroke width in Tailwind, we use the following classes:

ClassesOverview
stroke-0Used to set the stroke width of an SVG to 0.
stroke-1This class is used to define the stroke width of an element as 1px.
stroke-2In this case, the stroke width of an element is specified as 2px.
Note: These classes can be used in conjunction with other Tailwind classes to create custom styles for your elements.

Syntax

<svg class="stroke-{width}">...</svg>

Using Tailwind stroke width is easy. You can add a stroke width class to an element.

The following example showcases the implementation of the stroke width class in Tailwind:

Example: 

<!DOCTYPE html> <html><head> <script src="https://cdn.tailwindcss.com"></script> </head> <body class="m-3 text-center"> <h1 class="text-gray-700 text-2xl font-semibold"> MrExamples </h1> <p class="my-2 font-medium">Stroke Width Class in Tailwind</p> <div class="bg-gray-500 grid grid-flow-col w-fit p-4 mx-auto mt-4 rounded"> <svg height="100px" width="350px" xmlns="http://www.mrexamples.com/2000/svg" version="1.1"> <rect class="stroke-current text-yellow-400 stroke-0" x="10" y="10" width="80" height="80"></rect> <rect class="stroke-current text-yellow-400 stroke-1" x="120" y="10" width="80" height="80"></rect> <rect class="stroke-current text-yellow-400 stroke-2" x="240" y="10" width="80" height="80"></rect> </svg> </div> </body> </html>

If you found this article informative, please share your feedback by leaving a reaction below.

We value your feedback.
+1
0
+1
0
+1
0
+1
0
+1
0
+1
0
+1
0

Subscribe To Our Newsletter
Enter your email to receive a weekly round-up of our best posts. Learn more!
icon

Leave a Reply

Your email address will not be published. Required fields are marked *