Aspect Ratio

@/components/kamod-ui/aspect-ratio

Photo

Installation

Import AspectRatio from `@/components/kamod-ui/aspect-ratio`.

pnpm add @kamod-ch/ui
import { AspectRatio } from "@/components/kamod-ui/aspect-ratio"
import { Image } from "@/components/kamod-ui/image";

Usage

Pass ratio as a number (e.g. 16/9). Put the image (or video) inside and size it with h-full w-full object-cover so it fills the box.

import { AspectRatio } from "@/components/kamod-ui/aspect-ratio";
<AspectRatio />
Example

Demo

Default widescreen frame with muted background and rounded corners.

Photo

Square

Use ratio={1 / 1} for square thumbnails or avatars.

Photo

Portrait

Use ratio={9 / 16} for vertical media.

Photo

API Reference

Component overview.

AspectRatio

Wrapper with CSS aspect-ratio; clip overflow. Child media should fill with h-full w-full object-cover.

PropTypeDefault
rationumber(required)
classstring-
childrenComponentChildren-

Accessibility Notes

Use Aspect Ratio with clear labels, keyboard-friendly interactions and semantic structure.