Tailwind CSS Width
Tailwind Width
The tailwind width utility classes allow you to easily control the width of elements in your web applications. With a wide range of options and flexibility, you can achieve responsive designs and fine-grained control over the width of your elements.
How to set Tailwind Width
You can set the Tailwind width of an element using the w-{size} utility class, where {size} represents the desired width. The {size} can be a fixed width in pixels (e.g., w-64), a relative width using a fraction (e.g., w-1/2), or a percentage width (e.g., w-1/4 or w-25).
<div class="w-12"> <div class="w-14...">w-14</div> <div class="w-16 ">w-16</div> <div class="w-32">w-32</div></div>Preview
Tailwind Fixed Width
To apply a fixed width to an element, you can use classes like w-px, w-1, w-4, w-8, etc. Each of these classes corresponds to a specific width in pixels, calculated based on the root font size (by default, 1rem is equal to 16px).
<div class="flex..."> <div class="w-20...">w-20</div> <div class="w-32...">w-32</div> <div class="w-40...">w-40</div> <div class="w-60...">w-60</div> <div class="w-80...">w-80</div> <div class="w-96...">w-96</div></div>Preview
Tailwind Width Percentage
For a more fluid design, Tailwind provides classes for percentage-based widths. These are especially useful for creating responsive layouts.
<div class="bg-green-500 w-full">w-full</div><div class="flex..."><div class=" bg-green-500 w-4/5">w-4/5</div><div class=" bg-green-500 w-1/6">w-1/2</div></div><div class="flex..."><div class=" bg-green-500 w-4/5">w-4/5</div><div class=" bg-green-500 w-1/5">w-1/5</div></div><div class="flex..."><div class=" bg-green-500 w-3/4">w-3/4</div><div class=" bg-green-500 w-1/4">w-1/4</div></div><div class="flex..."><div class=" bg-green-500 w-2/3">w-2/3</div><div class=" bg-green-500 w-1/3">w-1/3</div></div><div class="flex..."><div class=" bg-green-500 w-1/2">w-1/2</div><div class=" bg-green-500 w-1/2">w-1/2</div>Preview
Tailwind ViewPoint Width
Sometimes, you might want an element to span the entire width of the viewport. Tailwind has classes like w-screen for full viewport width.
<div class="w-screen">...</div>Responsive Tailwind Width
Tailwind CSS also offers responsive width utility classes, allowing you to control the width of elements at different breakpoints. To use responsive tailwind width classes, you can append the breakpoint prefix to the width class. For example, md:w-1/2 sets the width to 50% starting from the medium breakpoint and above
<div class="w-full md:w-1/2 lg:w-1/4"> Full width on mobile, half width on medium screens, and quarter width on large screens</div>Customizing Tailwind Width
Tailwind CSS provides an extensive configuration file that allows you to customize various aspects of the framework, including width values. You can refer to the official Tailwind CSS documentation on customizing the configuration to learn more about modifying the default width values.
Tailwind Width Class
| Class | Properties |
|---|---|
| w-0 | width: 0px; |
| w-0.5 | width: 0.125rem; |
| w-1 | width: 0.25rem; |
| w-1.5 | width: 0.375rem; |
| w-2 | width: 0.5rem; |
| w-2.5 | width: 0.625rem; |
| w-3 | width: 0.75rem; |
| w-3.5 | width: 0.875rem; |
| w-4 | width: 1rem; |
| w-5 | width: 1.25rem; |
| w-6 | width: 1.5rem; |
| w-7 | width: 1.75rem; |
| w-8 | width: 2rem; |
| w-9 | width: 2.25rem; |
| w-10 | width: 2.5rem; |
| w-11 | width: 2.75rem; |
| w-12 | width: 3rem; |
| w-14 | width: 3.5rem; |
| w-16 | width: 4rem; |
| w-20 | width: 5rem; |
| w-24 | width: 6rem; |
| w-28 | width: 7rem; |
| w-32 | width: 8rem; |
| w-36 | width: 9rem; |
| w-40 | width: 10rem; |
| w-44 | width: 11rem; |
| w-48 | width: 12rem; |
| w-52 | width: 13rem; |
| w-56 | width: 14rem; |
| w-60 | width: 15rem; |
| w-64 | width: 16rem; |
| w-72 | width: 18rem; |
| w-80 | width: 20rem; |
| w-96 | width: 24rem; |
| w-auto | width: auto; |
| w-px | width: 1px; |
| w-1/2 | width: 50%; |
| w-1/3 | width: 33.333333%; |
| w-2/3 | width: 66.666667%; |
| w-1/4 | width: 25%; |
| w-2/4 | width: 50%; |
| w-3/4 | width: 75%; |
| w-1/5 | width: 20%; |
| w-2/5 | width: 40%; |
| w-3/5 | width: 60%; |
| w-4/5 | width: 80%; |
| w-1/6 | width: 16.666667%; |
| w-2/6 | width: 33.333333%; |
| w-3/6 | width: 50%; |
| w-4/6 | width: 66.666667%; |
| w-5/6 | width: 83.333333%; |
| w-1/12 | width: 8.333333%; |
| w-2/12 | width: 16.666667%; |
| w-3/12 | width: 25%; |
| w-4/12 | width: 33.333333%; |
| w-5/12 | width: 41.666667%; |
| w-6/12 | width: 50%; |
| w-7/12 | width: 58.333333%; |
| w-8/12 | width: 66.666667%; |
| w-9/12 | width: 75%; |
| w-10/12 | width: 83.333333%; |
| w-11/12 | width: 91.666667%; |
| w-full | width: 100%; |
| w-screen | width: 100vw; |
| w-min | width: min-content; |
| w-max | width: max-content; |
Windframe Tailwind blocks
Build modern projects using Bootstrap 5 and Contrast
Trying to create components and pages for a web app or website from
scratch while maintaining a modern User interface can be very tedious.
This is why we created Contrast, to help drastically reduce the amount of time we spend doing that.
so we can focus on building some other aspects of the project.
Contrast Bootstrap PRO consists of a Premium UI Kit Library featuring over 10000+ component variants.
Which even comes bundled together with its own admin template comprising of 5 admin dashboards and 23+ additional admin and multipurpose pages for
building almost any type of website or web app.
See a demo and learn more about Contrast Bootstrap Pro by clicking here.