components

Aspect Ratio

Displays content with a desired ratio

Source CodeRadix UI
Loading

Installation

Usage

Imports

/components/ui/aspect-ratio

Code

/components/ui/aspect-ratio

How Radix Aspect Ratio Works

The AspectRatio component ensures that the height is always calculated from the width, keeping the specified ratio intact. If you apply a fixed height, the component can’t maintain the ratio as intended.

If you need a fixed height, simply avoid using AspectRatio. Set the height directly and let the width adjust normally.

Examples

Ratio - 9:16

Loading

Ratio - 4:3

Loading

Ratio - 1:1

Loading

Props

<AspectRatio>
NameDefaultValues
External Reference--