AspectRatio
v1.0.1Updated 20 Jul 2026Locks content to a fixed width÷height ratio while the width stays fluid. Built on Radix AspectRatio with preset ratio strings, corner rounding, and automatic media fitting: direct img / video / iframe children are stretc
Preview
Live · 9 storiesDefaultOpen ↗
▸Why this is recommendedratiomediaimagevideo+3
The default, out-of-the-box AspectRatio.
Recommended for+14
- ✓Product photo thumbnails
- ✓Card hero images
- ✓Video embeds (16:9)
- ✓Social/story previews (9:16)
- ✓Banner strips (21:9)
Tags+6
ratiomediaimagevideothumbnailradixdefault
Features+4
- Preset ratio strings: 1:1 / 4:3 / 16:9 / 21:9 / 3:4 / 9:16
- Raw numeric ratios (e.g. 2.35 cinemascope)
- Invalid ratios safely fall back to 1
- Rounding presets: none / sm / md / lg / xl
- overflow-hidden frame owns the clipping
- Direct img / video / iframe children auto-fill with object-cover
- className passthrough on the root
- Purely presentational — no ARIA of its own; media children keep their alt text
Not recommended for−2
- ✕Intrinsic-size images that should not crop (use plain img)
- ✕Full-bleed backgrounds (use CSS background sizing)
Install
Ask your agent, or call the MCP tool directly. The resolved bundle is written into your project.
Usage
Tick variants in the left menu — each adds a tab with that variant’s real story source, the same code the preview above renders.
Props
PropTypeRequired
ratioWidth ÷ height; preset string or any positive number (default 16:9)
—roundedCorner rounding applied to the clipped frame (default lg)
—classNameExtra classes merged onto the frame
—