Trên trang này

Trang này chưa có bản tiếng Việt, nội dung bên dưới là bản tiếng Anh. Xem trang tiếng Anh

Aspect ratio

Install, props and the parts Aspect ratio is built from.

Install

Run this in the app, after shadcn-vue init and the Beehexa theme (Button › Code):

npx shadcn-vue@latest add https://beehexa.design/r/aspect-ratio.json

Use

<script setup lang="ts">
import { AspectRatio } from '@/components/ui/aspect-ratio'
</script>

<template>
  <AspectRatio :ratio="4 / 3">
    <img src="/products/green-tea.jpg" alt="Jasmine green tea, 100 g" class="size-full rounded-(--bh-radius-card) object-cover">
  </AspectRatio>
</template>

Props

Prop Values Notes
ratio number Width divided by height. Default 1
as, as-child element or boolean The element that holds the ratio

The default slot gets aspect, the ratio in use.

Built on

The reka-ui AspectRatio, unchanged, as the shadcn-vue Aspect Ratio. It has no Beehexa styles.