1. Layout
  2. aspect-ratio

Layout

aspect-ratio

Handy classes for locking in the aspect ratio of any element.

ClassStyles
aspect-<ratio>
aspect-ratio: <ratio>;
aspect-square
aspect-ratio: 1 / 1;
aspect-video
aspect-ratio: var(--aspect-video); /* 16 / 9 */
aspect-auto
aspect-ratio: auto;
aspect-(<custom-property>)
aspect-ratio: var(<custom-property>);
aspect-[<value>]
aspect-ratio: <value>;

Examples

Quick example

Reach for aspect-<ratio> utilities such as aspect-3/2 when an element needs a specific aspect ratio:

Scale the preview to watch the expected behavior kick in.

<img class="aspect-3/2 object-cover ..." src="/img/villas.jpg" />

Applying a video aspect ratio

Reach for the aspect-video utility to lock a video element to a 16 / 9 aspect ratio:

Scale the preview to watch the expected behavior kick in.

<iframe class="aspect-video ..." src="https://www.youtube.com/embed/dQw4w9WgXcQ"></iframe>

Setting a custom value

Reach for the aspect-[<value>] syntax to define the aspect ratio from an entirely custom value:

<img class="aspect-[calc(4*3+1)/3] ..." src="/img/villas.jpg" />

When you are working with CSS variables, the aspect-(<custom-property>) syntax works as well:

<img class="aspect-(--my-aspect-ratio) ..." src="/img/villas.jpg" />

It is simply shorthand for aspect-[var(<custom-property>)] that wraps things in the var() function on your behalf.

Responsive design

Add a breakpoint variant such as md: in front of an aspect-ratio utility so it only kicks in from medium screens on up:

<iframe class="aspect-video md:aspect-square ..." src="https://www.youtube.com/embed/dQw4w9WgXcQ"></iframe>

Read up on how variants work over in the variants documentation.

Customizing your theme

Tweak the --aspect-* theme variables to tailor the aspect ratio utilities across your whole project:

@theme {  --aspect-retro: 4 / 3; }

From there, the aspect - retro utility is ready to drop straight into your markup:

<iframe class="aspect-retro" src="https://www.youtube.com/embed/dQw4w9WgXcQ"></iframe>

Dig deeper into theming your setup over in the theme documentation.

Build UIs that truly shine — 5-day mini-course

5-day mini-course

Build UIs that feel great.

Short, hands-on video lessons from the folks behind Breezel, delivered straight to your inbox every day for a full week.

Get the free course

Copyright © 2026 Breezel, Inc.·Trademark Policy