AspectRatio
Reserves a box with a fixed width-to-height ratio using CSS aspect-ratio.
Usage
Wrap any content whose height should track its width. The child fills the reserved frame — pair with w-full h-full or absolute positioning.
Anatomy
<script setup lang="ts">
import { AspectRatio } from '@vuetify/v0'
</script>
<template>
<AspectRatio />
</template>Examples
Recipes
Video embed
<template>
<AspectRatio :ratio="16 / 9" class="w-full">
<iframe
class="w-full h-full"
src="https://www.youtube.com/embed/..."
/>
</AspectRatio>
</template>Square thumbnail grid
<template>
<div class="grid grid-cols-3 gap-2">
<AspectRatio v-for="photo in photos" :key="photo.id" :ratio="1">
<img :src="photo.src" class="w-full h-full object-cover" />
</AspectRatio>
</div>
</template>Number or string
ratio accepts either form. Both produce the same output:
<template>
<AspectRatio :ratio="16 / 9" /> <!-- number: 1.777... -->
<AspectRatio ratio="16 / 9" /> <!-- string -->
</template>Accessibility
AspectRatio is a presentational primitive — it renders a <div> with an inline style and no semantics of its own. Any ARIA attributes belong on the content inside. Pass as to change the element when a different semantic wrapper is needed (e.g. as="figure").
FAQ
You can, and for static layouts it’s fine. Reach for AspectRatio when the ratio is dynamic, when you want the intent to be visible at the call site, or when the same frame wraps more than one piece of content (placeholder, image, fallback) and all three need to share the reservation.
If the child should fill the frame, yes. aspect-ratio only reserves the box — it doesn’t size the child. Using object-cover on media is the usual pairing. Absolute positioning (position: absolute; inset: 0) on the child also works and is what layered compositions (image + placeholder + fallback) typically use.
Yes — put AspectRatio on the outside. Image.Root then participates in the reserved frame without needing its own width/height, and the placeholder and fallback sit inside the same box. See the responsive example.
No. aspect-ratio is an inline style that renders identically on server and client, so there’s no hydration mismatch and no layout shift on hydration.
CSS aspect-ratio is supported in all modern browsers (Chrome 88+, Firefox 89+, Safari 15+). Legacy fallbacks (padding-bottom hack) are not provided — if you need to support older browsers, add your own fallback.