Aspect Ratio Examples
7 fixed-ratio frames: 16:9 widescreen, 1:1 square, 4:3 traditional, 21:9 ultrawide, 9:16 vertical, 3:2 photography, and 2:1 panoramic. Images and video without layout shift. Each on React, Vue, Svelte and Solid, with Base UI, React Aria, Ark UI or Radix UI on React.
Every aspect ratio example
7 examples.
- 1:1 Aspect Ratio (Square)StandardA square frame, as tall as it is wide, with the label 1:1 centered in a muted box. The width follows the parent.

- 16:9 Aspect Ratio (Widescreen)StandardA widescreen frame at 16:9, with that label centered in a muted box. The height follows the width.

- 2:1 Aspect Ratio (Panoramic)StandardA panoramic frame that is twice as wide as it is tall, with the label 2:1 centered in a muted box.

- 21:9 Aspect Ratio (Ultrawide)StandardAn ultrawide frame at 21:9, with that label centered in a muted box. The frame is much wider than it is tall.

- 3:2 Aspect Ratio (Photography)StandardA 3:2 frame, the proportions of most camera sensors, with the label 3:2 centered in a muted box.

- 4:3 Aspect Ratio (Traditional)StandardA 4:3 frame, taller than widescreen, with that label centered in a muted box. The height follows the width.

- 9:16 Aspect Ratio (Vertical/Mobile)StandardA tall 9:16 frame with that label centered in a muted box. The width is capped so the frame does not grow too high.

Or describe it. With Pro, your AI agent installs the aspect ratio example you describe, on your framework and UI library.
Get ProGalleries
More component examples
8 related galleries, free: open one for its live examples and their code.
Pricing
Aspect Ratio examples MCP, with Pro
Your AI agent installs any of the 1364 examples, and every component, block and icon, with every Pro plan.
4.9/5 out of 5 · 150+ reviewsfrom 150+ founders and developers.
- Secure checkout via Stripe
- Code lives in your repo
- Keep what you've shipped if you cancel
- License terms
FAQ
Frequently asked questions
An aspect ratio is a layout container that keeps its content at a fixed width-to-height ratio: 16:9 for widescreen video, 4:3 for traditional media, 1:1 for square crops, 21:9 for ultrawide banners. It's shadcn.io's AspectRatio component, built on Base UI, React Aria, Ark UI and Radix UI for React, and on Ark UI for Vue, Svelte and Solid, and styled with Tailwind CSS. Each example is one small file.
Yes. Every aspect ratio example is free to use in personal and commercial projects, with no attribution required. Seeing the code and installing an example takes a free shadcn.io account.
Both keep a box at a fixed shape. AspectRatio gives that shape one `ratio` prop, a number you can compute, such as `16 / 9` or `1.618`, instead of a class per ratio, and keeps the same API on every framework and library. For a fixed ratio in a single place, Tailwind's `aspect-video` or `aspect-square` is enough.
Use AspectRatio when the container must reserve space before its content loads: images, videos, embedded iframes, skeleton placeholders. Letting the image set the height shifts the layout when it arrives. Content whose size is known at render time, such as text or icons, doesn't need it.
Most video, from YouTube and Vimeo to HTML5 players, is 16:9, so the widescreen example fits single-video embeds. Use 9:16 for vertical mobile video such as stories and reels, 21:9 for cinematic trailers, and 3:2 for camera photos. Matching the ratio to the source avoids letterboxing.
Square works for product thumbnails, avatar grids, social preview cards, and galleries where a consistent tile size matters more than showing the whole image. Pair it with `object-cover` on the image so it fills the square without distortion; the edges get cropped.
Two choices. `object-cover` fills the frame and crops the overflow, best for photos whose subject sits near the center. `object-contain` fits the whole image inside and leaves bars, best for product shots and artwork; give the frame a background such as `bg-muted` so the bars look intended.
Yes. The frame takes its width from its parent, so a responsive width gives a responsive height. To change the ratio itself per breakpoint, render one frame per ratio and show one at a time with `hidden md:block`. For a hero that fills the viewport, use `h-screen` instead: a ratio is about the content's shape, not the screen's.
Sign in with a free account, then copy the code or run the install command on the example's page. It adds the example and the AspectRatio component to your project if you don't have it yet. Then replace the placeholder with your own image or video.
`ratio` takes any positive number, width divided by height: `16 / 9` for widescreen, `3 / 4` for portrait, `1.618` for the golden ratio. The default is `1`, a square.
Give the frame's parent a width, such as `w-full max-w-md` or a grid cell. The height follows the width and the ratio, so the frame resizes with its container without any JavaScript.
Yes. Put one child in the frame and make it fill it: `absolute inset-0 size-full` on an image, a video or an iframe, plus `object-cover` on media. Give an iframe a `title` and check that its source supports the ratio you chose, or its content letterboxes inside.
Only the AspectRatio component and Tailwind CSS. There's no state and no icon library in these examples. The labels inside the frames are placeholders for your own images or video.
The frame is a layout wrapper with no meaning for assistive technology, so accessibility comes from its content: meaningful `alt` text on images, captions on videos, a `title` on iframes. Give decorative images an empty `alt` so screen readers skip them.
The examples are static markup with no state, so on React they render as Server Components and need no client boundary of their own. Only interactive content inside the frame, such as a video player, needs one.
The examples are written for Tailwind CSS v4, the version shadcn.io's components use, and use its class names and design tokens such as `bg-muted`.
4.9 out of 5 from 150+ developers
Every aspect ratio example. One prompt away.
Every aspect ratio example is free with an account. With Pro, your AI agent installs them from a prompt.
Get Pro















