Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Aspect Ratio examples · Standard

21:9 Aspect Ratio (Ultrawide) for React

A 21:9 ultrawide frame for cinematic content, immersive banners, and ultrawide displays.

Framework
UI library

Cinematic width demands attention. This example sets ratio to 21 / 9 on AspectRatio, matching cinema screens and ultrawide monitors, and the frame reserves its height before the media loads. The width comes from the parent, capped here with max-w-md, and the height follows the ratio. Use it for film trailers, panoramic imagery, and immersive hero sections.

Preview

Preview width
21:9

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

FAQ

How is 21:9 set on this frame?

ratio is 21 / 9 on AspectRatio, width divided by height. That is a very wide frame, so at the same width it is shorter than 16:9. The centered label reads "21:9".

Where does the frame's width come from?

The parent is w-full max-w-md. The height follows that width. Give the wrapper a width, because a ratio with no width can collapse. max-w-md caps the width, and the height stays a short band.

How does the label fill the frame?

The child is a div with size-full, flex items-center justify-center, rounded-md, and bg-muted. The span is text-sm text-muted-foreground. Those classes are on the child, so the frame's shape stays on ratio.

How does ratio become a height?

The ratio is stored in the --ratio custom property, and the aspect-ratio utility reads that variable.

How do I put an image or a video in this frame?

Put one child in AspectRatio and make it fill the box. The Aspect Ratio usage places the image absolutely, inset on every side, at full size, with object-cover. This file's child is the muted "21:9" label.

What happens if I omit ratio?

The default is 1, a square. This file sets 21 / 9 so the frame stays that wide shape.