--- name: layout-height description: Setting element height with spacing scale, fractions, viewport units, and content-based sizing --- # Height Utilities for setting the height of an element. ## Usage ### Spacing scale Use `h-` utilities based on the spacing scale: ```html
h-24
h-48
h-64
``` ### Percentage heights Use `h-full` or `h-` for percentage-based heights: ```html
100%
50%
75%
90%
``` ### Viewport units Use `h-screen` for full viewport height, or dynamic viewport units: ```html
Full viewport height (100vh)
Dynamic viewport height
Small viewport height
Large viewport height
``` ### Content-based heights Use `h-auto`, `h-fit`, `h-min`, `h-max` for content-based sizing: ```html
Auto height
Fit content
Min content
Max content
``` ### Line height Use `h-lh` to match line height: ```html
Matches line height
``` ### Size utility Use `size-` to set both width and height: ```html
16x16
24x24
100% x 100%
``` ### Custom values Use arbitrary values for custom heights: ```html
Custom pixel height
Custom viewport height
Custom calculation
``` ## Key Points - Spacing scale: `h-0` through `h-96` (and beyond) - Fractions: `h-1/2`, `h-1/3`, `h-2/3`, `h-1/4`, `h-3/4`, `h-9/10` - Viewport units: `h-screen` (100vh), `h-dvh`, `h-svh`, `h-lvh` - `h-dvh` adapts to browser UI (address bar, etc.) - `h-svh` uses smallest viewport height - `h-lvh` uses largest viewport height - `size-*` utilities set both width and height simultaneously - Use `h-auto` to reset height at specific breakpoints