Aspect Ratio

Displays content within a desired ratio.

Landscape photograph by Tobias Tullius

Installation

npx @kosori/cli add components aspect-ratio

Usage

import Image from 'next/image';
 
import { AspectRatio } from '~/components/ui/aspect-ratio';
<div className='w-[450px]'>
  <AspectRatio ratio={16 / 9}>
    <Image src='...' alt='Image' className='rounded-md object-cover' />
  </AspectRatio>
</div>

Examples

Video (16:9)

Landscape photograph by Tobias Tullius

Square (1:1)

Landscape photograph by Tobias Tullius

Portrait (9:16)

Landscape photograph by Tobias Tullius

On this page