Skip to content

Width

Use width utilities to set an element’s width using the spacing scale, fractional percentages, the container scale, or viewport units. Tailwind v4 ships numeric (w-<number>), fractional (w-1/2, w-2/3, …), container-scale (w-3xsw-7xl), and viewport (w-screen, w-svw/w-lvw/w-dvw) variants on a single resolver.

Use w-<number> utilities like w-24 and w-64 to set an element to a fixed width based on the spacing scale.

Style('w-96 ...', child: Text('w-96'))
Style('w-80 ...', child: Text('w-80'))
Style('w-64 ...', child: Text('w-64'))
Style('w-48 ...', child: Text('w-48'))
Style('w-40 ...', child: Text('w-40'))
Style('w-32 ...', child: Text('w-32'))
Style('w-24 ...', child: Text('w-24'))

Use w-full or w-<fraction> utilities like w-1/2 and w-2/5 to give an element a percentage-based width. Fractions render via Flutter’s FractionallySizedBox against the parent’s available width.

Style('flex ...', children: [
Style('w-1/2 ...', child: Text('w-1/2')),
Style('w-1/2 ...', child: Text('w-1/2')),
])
Style('flex ...', children: [
Style('w-2/5 ...', child: Text('w-2/5')),
Style('w-3/5 ...', child: Text('w-3/5')),
])
Style('flex ...', children: [
Style('w-1/3 ...', child: Text('w-1/3')),
Style('w-2/3 ...', child: Text('w-2/3')),
])
Style('flex ...', children: [
Style('w-1/4 ...', child: Text('w-1/4')),
Style('w-3/4 ...', child: Text('w-3/4')),
])
Style('flex ...', children: [
Style('w-1/5 ...', child: Text('w-1/5')),
Style('w-4/5 ...', child: Text('w-4/5')),
])
Style('flex ...', children: [
Style('w-1/6 ...', child: Text('w-1/6')),
Style('w-5/6 ...', child: Text('w-5/6')),
])
Style('w-full ...', child: Text('w-full'))

Use utilities like w-sm and w-xl to set an element to a fixed width based on the container scale. The same 3xs7xl keys are also available on min-w-* and max-w-*.

Style('w-xl ...', child: Text('w-xl'))
Style('w-lg ...', child: Text('w-lg'))
Style('w-md ...', child: Text('w-md'))
Style('w-sm ...', child: Text('w-sm'))
Style('w-xs ...', child: Text('w-xs'))
Style('w-2xs ...', child: Text('w-2xs'))
Style('w-3xs ...', child: Text('w-3xs'))

Use the w-screen utility to make an element span the entire width of the viewport:

Style('w-screen', child: /* ... */)

Alternatively, you can match the width of the large, small, or dynamic viewports using the w-lvw, w-svw, and w-dvw utilities. In Flutter all four collapse to a single MediaQuery.sizeOf(context).width read at render time — there is no static / large / dynamic viewport distinction.

Use the w-auto utility to remove an element’s assigned width under a specific condition, like at a particular breakpoint:

Style('w-full md:w-auto', child: /* ... */)

Use utilities like size-px, size-4, and size-full to set both the width and height of an element at the same time. Fractional size-<n>/<m> is also supported.

Style('size-16 ...', child: Text('size-16'))
Style('size-20 ...', child: Text('size-20'))
Style('size-24 ...', child: Text('size-24'))
Style('size-32 ...', child: Text('size-32'))
Style('size-40 ...', child: Text('size-40'))

Use bracket syntax for arbitrary values. Lengths like w-[5px], w-[12rem], and size-[48px] strip their unit suffix (px, rem, em — Flutter uses logical pixels):

Style('w-[5px]', child: /* ... */)

A percentage such as w-[50%] is taken relative to the parent and renders through Flutter’s FractionallySizedBox — the same path as the w-1/2 fractions, but accepting any value (including decimals no fraction provides, e.g. w-[37.5%]). Percentages work the same on h, min-w/min-h, max-w/max-h, and size.

Style('w-[37.5%] ...', child: Text('w-[37.5%]'))
ClassValue
w-<number>spacing scale × <number> (e.g. w-4 = 16px)
w-<fraction><fraction> × parent width (e.g. w-1/2 = 50%)
w-3xs256px
w-2xs288px
w-xs320px
w-sm384px
w-md448px
w-lg512px
w-xl576px
w-2xl672px
w-3xl768px
w-4xl896px
w-5xl1024px
w-6xl1152px
w-7xl1280px
w-autono constraint
w-px1px
w-full100% (infinity)
w-screenviewport width (MediaQuery.sizeOf(context).width)
w-dvw / w-lvw / w-svwviewport width (collapsed; Flutter has no dynamic-viewport distinction)
w-dvh / w-lvh / w-svhviewport height (used as width)
w-[<value>]arbitrary value — length (units stripped) or percentage (e.g. w-[50%] → factor of parent)

size-<n> mirrors the full surface and applies the same value to both width and height.

w-(<custom-property>) / size-(<custom-property>) are resolved against theme-defined StyleThemeData.customProperties — e.g. w-(--my-width) behaves like w-[200px] when the theme defines --my-width: '200px'. Cascade-inherited or JS-set CSS variables remain out of scope.

  • w-min / w-max / w-fit — content-based sizing. Maps to Flutter’s IntrinsicWidth/IntrinsicHeight. Tracked for a future PR — playground pages must avoid IntrinsicWidth for performance, but the library can expose them when a docs page exercises them.