Browse documentation
Reference / Sizing
Width
Set an element’s width using a spacing token, a fraction of its parent, an intrinsic size or a CSS length.
Working example
Half
Two thirds
Full
A fraction uses the containing block’s width. A viewport unit measures the browser viewport even when the element sits in a narrow column.
<div class="space-y-2">
<div class="w-1/2 bg-neutral-200 px-2">Half</div>
<div class="w-2/3 bg-neutral-200 px-2">Two thirds</div>
<div class="w-full bg-neutral-200 px-2">Full</div>
</div>Class reference
| Class | CSS declarations |
|---|---|
w-12 | width: 3rem; |
w-1/2 | width: 50%; |
w-2/3 | width: 66.66666666666666%; |
w-full | width: 100%; |
w-fit | width: fit-content; |
w-min | width: min-content; |
w-max | width: max-content; |
w-auto | width: auto; |
w-screen | width: 100vw; |
w-[18ch] | width: 18ch; |
View full generated CSS
.w-1\/2 {
width: 50%;
}
.w-12 {
width: 3rem;
}
.w-2\/3 {
width: 66.66666666666666%;
}
.w-\[18ch\] {
width: 18ch;
}
.w-auto {
width: auto;
}
.w-fit {
width: fit-content;
}
.w-full {
width: 100%;
}
.w-max {
width: max-content;
}
.w-min {
width: min-content;
}
.w-screen {
width: 100vw;
}