Search

Search documentation

Aspect Ratio

Displays content within a desired ratio.

Installation

pnpm dlx shadcn@latest add @evolphin/aspect-ratio

Usage

import { AspectRatio } from "@/components/ui/aspect-ratio"
<AspectRatio ratio={16 / 9}>
  <img src="..." alt="Image" className="rounded-md object-cover" />
</AspectRatio>

Type Definitions

interface AspectRatioProps {
  /** The desired ratio */
  ratio?: number;
AspectRatioProps.ratio?: number | undefined

The desired ratio

}

Examples

Default

Photo by Drew Beamer

1:1 Ratio

Photo by Drew Beamer

API Reference

AspectRatio

PropTypeDefaultDescription
rationumber1The desired aspect ratio.
asChildbooleanfalseChange the component to the HTML tag or custom component of the only child.

On this page