Skip to content

Width & Height

Class names

The width class names start with w.

Fractional and keyword width classes also support responsive prefixes: sm:, md:, lg:, and xl: (e.g. sm:w-1/2). Responsive variants do not support the ! modifier.

ClassDescription! support
w-autoAuto width.Yes
w-4-12Width sizes 4 to 12.Yes
w-full100% width.Yes
w-minwidth: min-contentYes
w-maxwidth: max-contentYes
w-fitwidth: fit-contentYes
w-screenMakes the width equal to the screen size.Yes
w-dvwDynamic viewport width (100dvw).No
w-svwSmall viewport width (100svw).No
w-lvwLarge viewport width (100lvw).No
w-1/1010% width.Yes
w-1/250% width.Yes
w-1/333% width.Yes
w-1/425% width.Yes
w-1/520% width.Yes
w-2/366% width.Yes
w-2/540% width.Yes
w-3/475% width.Yes
w-3/560% width.Yes
w-4/580% width.Yes
w-9/1090% width.Yes
w-3xswidth: var(--container-3xs); /* 16rem (256px) */No
w-2xswidth: var(--container-2xs); /* 18rem (288px) */No
w-xswidth: var(--container-xs); /* 20rem (320px) */No
w-smwidth: var(--container-sm); /* 24rem (384px) */No
w-mdwidth: var(--container-md); /* 28rem (448px) */No
w-lgwidth: var(--container-lg); /* 32rem (512px) */No
w-xlwidth: var(--container-xl); /* 36rem (576px) */No
w-2xlwidth: var(--container-2xl); /* 42rem (672px) */No
w-3xlwidth: var(--container-3xl); /* 48rem (768px) */No
w-4xlwidth: var(--container-4xl); /* 56rem (896px) */No
w-5xlwidth: var(--container-5xl); /* 64rem (1024px) */No
w-6xlwidth: var(--container-6xl); /* 72rem (1152px) */No
w-7xlwidth: var(--container-7xl); /* 80rem (1280px) */No
w-8xlwidth: var(--container-8xl); /* 90rem (1440px) */No
w-9xlwidth: var(--container-9xl); /* 96rem (1536px) */No
w-10xlwidth: var(--container-10xl); /* 100rem (1600px) */No

The minimum width class names start with min-w.

ClassDescription! support
min-w-0Minimum width of 0 px.No
min-w-4-12Minimum width sizes 4 to 12.No
min-w-3xsmin-width: var(--container-3xs); /* 16rem (256px) */No
min-w-2xsmin-width: var(--container-2xs); /* 18rem (288px) */No
min-w-xsmin-width: var(--container-xs); /* 20rem (320px) */No
min-w-smmin-width: var(--container-sm); /* 24rem (384px) */No
min-w-mdmin-width: var(--container-md); /* 28rem (448px) */No
min-w-lgmin-width: var(--container-lg); /* 32rem (512px) */No
min-w-xlmin-width: var(--container-xl); /* 36rem (576px) */No
min-w-2xlmin-width: var(--container-2xl); /* 42rem (672px) */No
min-w-3xlmin-width: var(--container-3xl); /* 48rem (768px) */No
min-w-4xlmin-width: var(--container-4xl); /* 56rem (896px) */No
min-w-5xlmin-width: var(--container-5xl); /* 64rem (1024px) */No
min-w-6xlmin-width: var(--container-6xl); /* 72rem (1152px) */No
min-w-7xlmin-width: var(--container-7xl); /* 80rem (1280px) */No
min-w-8xlmin-width: var(--container-8xl); /* 90rem (1440px) */No
min-w-9xlmin-width: var(--container-9xl); /* 96rem (1536px) */No
min-w-10xlmin-width: var(--container-10xl); /* 100rem (1600px) */No

The maximum width class names start with min-w.

ClassDescription! support
max-w-screenSets maximum width to the width of the screen.No
max-w-dvwSets maximum width to the dynamic width of the screen.No
max-w-4-12Maximum width sizes 4 to 12.No
max-w-3xsmax-width: var(--container-3xs); /* 16rem (256px) */No
max-w-2xsmax-width: var(--container-2xs); /* 18rem (288px) */No
max-w-xsmax-width: var(--container-xs); /* 20rem (320px) */No
max-w-smmax-width: var(--container-sm); /* 24rem (384px) */No
max-w-mdmax-width: var(--container-md); /* 28rem (448px) */No
max-w-lgmax-width: var(--container-lg); /* 32rem (512px) */No
max-w-xlmax-width: var(--container-xl); /* 36rem (576px) */No
max-w-2xlmax-width: var(--container-2xl); /* 42rem (672px) */No
max-w-3xlmax-width: var(--container-3xl); /* 48rem (768px) */No
max-w-4xlmax-width: var(--container-4xl); /* 56rem (896px) */No
max-w-5xlmax-width: var(--container-5xl); /* 64rem (1024px) */No
max-w-6xlmax-width: var(--container-6xl); /* 72rem (1152px) */No
max-w-7xlmax-width: var(--container-7xl); /* 80rem (1280px) */No
max-w-8xlmax-width: var(--container-8xl); /* 90rem (1440px) */No
max-w-9xlmax-width: var(--container-9xl); /* 96rem (1536px) */No
max-w-10xlmax-width: var(--container-10xl); /* 100rem (1600px) */No

The height class names start with h.

ClassDescription! support
h-autoAuto height.Yes
h-4-12Height sizes 4 to 12.Yes
h-full100% height.Yes
h-minheight: min-contentYes
h-maxheight: max-contentYes
h-fitheight: fit-contentYes
h-screenMakes the height equal to the screen size.Yes
h-dvhDynamic viewport height (100dvh).No
h-lvhLarge viewport height (100lvh).No
h-svhSmall viewport height (100svh).No
h-1/250% height.Yes

The minimum and maximum height class names start with min-h and max-h.

ClassDescription! support
max-h-4-12Maximum height sizes 4 to 12.No
min-h-4-12Minimum height sizes 4 to 12.No

In case both width and height have to be applied and they must be the same, the size-* class can be used with a range from 4 to 12.

ClassDescription! support
size-fullFull size container.Yes
size-fitFit the container size to content.Yes
size-4-12Width and height sizes 4 to 12.Yes
min-size-4Minimum width and height of var(--spacing)*4. Used for icons.No

INFO

Some of the classes above can be used with the ! prefix (for !important) in order to force their use in case the target element already has a certain size. The class names which support this are marked with "Yes" in the "! support" column.

Width examples

Screen

html
<div class="flex w-screen justify-between bg-primary text-primary-foreground">
  <span>Start</span>
  <span>End</span>
</div>

TIP

You may have to horizontally scroll the container to see the "End" label.

Full

html
<div class="w-full bg-primary text-primary-foreground">Full width</div>

Fractions

html
<div class="flex gap-2">
  <div class="w-1/2 bg-primary text-primary-foreground">w-1/2</div>
  <div class="w-1/2 bg-primary text-primary-foreground">w-1/2</div>
</div>
<div class="flex gap-2">
  <div class="w-2/5 bg-primary text-primary-foreground">w-2/5</div>
  <div class="w-3/5 bg-primary text-primary-foreground">w-3/5</div>
</div>
<div class="flex gap-2">
  <div class="w-1/3 bg-primary text-primary-foreground">w-1/3</div>
  <div class="w-2/3 bg-primary text-primary-foreground">w-2/3</div>
</div>
<div class="flex gap-2">
  <div class="w-1/4 bg-primary text-primary-foreground">w-1/4</div>
  <div class="w-3/4 bg-primary text-primary-foreground">w-3/4</div>
</div>
<div class="flex gap-2">
  <div class="w-1/5 bg-primary text-primary-foreground">w-1/5</div>
  <div class="w-4/5 bg-primary text-primary-foreground">w-4/5</div>
</div>
<div class="flex gap-2">
  <div class="w-1/10 bg-primary text-primary-foreground">w-1/10</div>
  <div class="w-9/10 bg-primary text-primary-foreground">w-9/10</div>
</div>

Sizes

html
<div class="w-xs bg-primary text-primary-foreground">Extra small width</div>
<div class="w-sm bg-primary text-primary-foreground">Small width</div>
<div class="w-md bg-primary text-primary-foreground">Medium width</div>
<div class="w-lg bg-primary text-primary-foreground">Large width</div>
<div class="w-xl bg-primary text-primary-foreground">Extra large width</div>

Height examples

Full

html
<div class="h-full bg-primary text-primary-foreground">Full height</div>

Screen

html
<div class="h-screen bg-primary text-primary-foreground">Matches screen height</div>

Half

html
<div class="h-1/2 bg-primary text-primary-foreground">50% height</div>

Size examples


html
<div class="size-8 bg-primary text-xs text-primary-foreground">Size 8</div>
html
<div class="size-12 bg-primary text-primary-foreground">Size 12</div>