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

A fraction uses the containing block’s width. A viewport unit measures the browser viewport even when the element sits in a narrow column.

HTML
<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

ClassCSS declarations
w-12width: 3rem;
w-1/2width: 50%;
w-2/3width: 66.66666666666666%;
w-fullwidth: 100%;
w-fitwidth: fit-content;
w-minwidth: min-content;
w-maxwidth: max-content;
w-autowidth: auto;
w-screenwidth: 100vw;
w-[18ch]width: 18ch;
View full generated CSS
Compiled 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;
}