1. Components
  2. Layout
  3. Aspect Ratio

Aspect Ratio

Displays content within a desired ratio.

Photo by Drew Beamer
<AspectRatio ratio={16 / 9}>
  <Image />
</AspectRatio>

Installation

npx dotui-cli@latest add aspect-ratio

Usage

Use the AspectRatio component to display content within a desired ratio.

Options

AsChild

Use the asChild prop to change the default rendered element for the one passed as a child, merging their props and behavior.

Photo by Drew Beamer
<AspectRatio ratio={16 / 9} asChild>
  <Image />
</AspectRatio>

API Reference

PropTypeDefaultDescription
asChild
boolean
false
Change the default rendered element for the one passed as a child, merging their props and behavior.
ratio
number
1
The desired ratio

Last updated on 10/11/2024