Aspect Ratio

Responsive media with smooth aspect ratio transitions.

Preview

A lakeside cabin beneath mountains, reflected in the water

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @beui/aspect-ratio

API Reference

AspectRatio

ratio?
number

Width divided by height, for example 16 / 9. Must be finite and positive.

1
animated?
boolean

Morph layout changes. Reduced motion always skips movement.

true
contentClassName?
string

Classes for the content layer, such as alignment or padding.

—
className?
string
—

AspectRatioImage

alt
string
—
width
number

Intrinsic width in pixels, used to reserve the image's cover crop.

—
height
number

Intrinsic height in pixels. Keep these dimensions accurate for the source.

—
className?
string
—

Updated