Skip to content

AspectRatio

Container that maintains a width / height ratio (16/9, 4/3, 1, custom). Built on Reka UI's AspectRatio primitive — useful for embeds, responsive images, and video thumbnails.

bash
npm install @vuecs/elements
vue
<script setup lang="ts">
import { VCAspectRatio } from '@vuecs/elements';
</script>

<template>
    <VCAspectRatio :ratio="16 / 9">
        <img src="/my-image.jpg" alt="..." />
    </VCAspectRatio>

    <VCAspectRatio :ratio="1">
        <img src="/avatar.jpg" alt="Square crop" />
    </VCAspectRatio>
</template>
css
@import "tailwindcss";
@import "@vuecs/design";
@import "@vuecs/elements";

Props

PropTypeDefaultDescription
rationumber1Desired width / height ratio (e.g. 16 / 9, 4 / 3, 1).
themeClassPartial<AspectRatioThemeClasses>undefinedPer-instance theme override.
themeVariantRecord<string, string | boolean>undefinedPer-instance variant values.

Theme keys

KeyDefault classNotes
rootvc-aspect-ratioWrapper that maintains the ratio via padding-bottom.

Released under the Apache 2.0 License.