Primary usage
Wrap media in AspectRatio so it keeps a consistent shape regardless of the source file's dimensions.
Displays content within a fixed aspect ratio.
bunx shadcn@latest add @nx-ui/aspect-ratioWrap media in AspectRatio so it keeps a consistent shape regardless of the source file's dimensions.
Site survey photography, drone stills and document scans each favour a different shape.
The ratio prop reads live from --ratio, so it can be driven by state — useful when a viewer lets users switch framing.
Reserve the frame with AspectRatio while media loads, so surrounding content doesn't jump.
A realistic composition: a fixed-ratio cover photo above a remediation project summary.
Exported parts and their props, extracted from the component source.
| Prop | Type | Default | Description |
|---|---|---|---|
ratio* | number | — | — |
…extends React.ComponentProps<"div">