Docs
Aspect Ratio

Aspect Ratio

Displays content within a desired ratio.

Loading...
Loading...

Installation

npx shadcn-ng@latest add aspect-ratio
npm
yarn
pnpm
bun

Install the following dependencies:

npm install @radix-ng/primitives
npm
yarn
pnpm
bun

Copy and paste the following code into your project.

Update the import paths to match your project setup.

Usage

import { UbAspectRatioDirective } from "@/components/ui/aspect-ratio"
<div ubAspectRatio [ratio]="16 / 9">
  <img src="..." alt="Image" class="rounded-md object-cover" >
</div>