--- name: layout-width description: Setting element width with spacing scale, fractions, container sizes, and viewport units --- # Width Utilities for setting the width of an element. ## Usage ### Spacing scale Use `w-` utilities based on the spacing scale: ```html
w-24
w-48
w-64
``` ### Percentage widths Use `w-full` or `w-` for percentage-based widths: ```html
50%
50%
40%
60%
100%
``` ### Container scale Use container size utilities like `w-sm`, `w-md`, `w-lg`: ```html
Small container
Medium container
Extra large container
``` ### Viewport units Use `w-screen` for full viewport width, or dynamic viewport units: ```html
Full viewport width
Dynamic viewport width
Small viewport width
Large viewport width
``` ### Content-based widths Use `w-auto`, `w-fit`, `w-min`, `w-max` for content-based sizing: ```html
Auto width
Fit content
Min content
Max content
``` ### Size utility Use `size-` to set both width and height: ```html
16x16
24x24
100% x 100%
``` ### Custom values Use arbitrary values for custom widths: ```html
Custom pixel width
Custom percentage
Custom calculation
``` ## Key Points - Spacing scale: `w-0` through `w-96` (and beyond) - Fractions: `w-1/2`, `w-1/3`, `w-2/3`, `w-1/4`, `w-3/4`, `w-1/5`, `w-4/5`, `w-1/6`, `w-5/6` - Container sizes: `w-3xs`, `w-2xs`, `w-xs`, `w-sm`, `w-md`, `w-lg`, `w-xl`, `w-2xl`, `w-3xl`, `w-4xl`, `w-5xl`, `w-6xl`, `w-7xl` - Viewport units: `w-screen` (100vw), `w-dvw`, `w-svw`, `w-lvw` - `size-*` utilities set both width and height simultaneously - Use `w-auto` to reset width at specific breakpoints