Skip to content

Aspect Ratio

Free

A box that keeps a width-to-height ratio, so photos and video keep their shape and the page does not move while they load. It can animate to a new ratio.

  • Base UI
  • Motion
  • React 19
  • Tailwind CSS 4

Added Nov 8, 2026 · MIT + Commons Clause

Playground

Loading the preview

Props

Set the ratio and put the media inside, so the box keeps its shape before the photo loads.

The sample also uses Image. One command adds them with this item:

article-cover.tsx

AspectRatio

<div>
PropTypeDefaultDescription
ratioRequirednumber—Width divided by height: 16 / 9, 4 / 3, 1, 9 / 16.
animatebooleanfalseMove to a new ratio on a spring. Default false: the box takes a new ratio at once, as a plain server-rendered div.
mode"crop""page"—With animate, how a new ratio shows. page (default): the box height moves, and layout runs each frame, so the content below flows with it. crop: the box keeps a fixed frame, and a clip-path: inset moves; no layout runs, so nothing below moves.
framenumber—With animate and mode="crop": the ratio of the fixed frame. Default 1: a square holds the contain box of every ratio. For a set of presets, use clamp(1, smallest, largest): 4:3 to 21:9 gives 4 / 3, and 16:9 with 9:16 gives 1.
transitionSpringConfig—With animate: the spring (SpringConfig, physics or time form). Default glide (stiffness 700, damping 53, no overshoot, within 0.5% at about 280ms). A time spring runs as its physics twin, so it keeps its speed when a new ratio comes mid-move.
...props<div> attributes—Every other attribute goes to the <div>, with a ref.
  • Use it for an image, a video, a map, or a placeholder of fixed shape.
  • Put the corners on the AspectRatio (overflow-hidden rounded-*), not on the image.
  • Set animate to move to a new ratio on a spring.
  • For a picture with a load state and a fallback, use an Image.
  • For a surface with a header and a body, use a Card.

It is a plain box with no role. The media inside it keeps its own name.

Ratio
glide · spring · the height moves to the new ratio
  1. AddedAspect Ratio.
Open the release