Components
Aspect ratio
Holds a ratio computed at runtime. Ratios known at build time need no component: aspect-video, aspect-square, aspect-[4/3].
Examples
Runtime ratio
Reach for the component when the ratio only exists at runtime. Tailwind compiles the classes it can read in the source, so an aspect-[] class assembled from a variable never becomes a rule; the component writes the value as an inline style instead.
Composition
Constrained media
- <AspectRatio>
- <img />
Installation
The Control UI source installs this primitive from src/registry/sources/control-ui/ui/aspect-ratio.tsx.
Raw code
Primary installed source