Aspect Ratio
Base UIA stable frame for images and other media.
ReadyResponsive
Usage
Package export"use client";
import { AspectRatio } from "@jnpll/elements-ui/aspect-ratio";
export default function AspectRatioDemo() { return <AspectRatio ratio={16 / 9} className="w-full max-w-sm"><img src="/samples/workspace.webp" alt="MacBook Pro on a workspace" className="size-full rounded-md object-contain bg-white" /></AspectRatio>; }
Examples
Default composition
"use client";
import { AspectRatio } from "@jnpll/elements-ui/aspect-ratio";
export default function AspectRatioDemo() { return <AspectRatio ratio={16 / 9} className="w-full max-w-sm"><img src="/samples/workspace.webp" alt="MacBook Pro on a workspace" className="size-full rounded-md object-contain bg-white" /></AspectRatio>; }
API Reference
| Prop | Type / description | Default |
|---|---|---|
ratio | numberWidth divided by height. | 1 |
className | stringAdditional classes, merged with the component styles. | - |
Composition & accessibility
Import the composition slots shown in the example. Keep labels and descriptions meaningful; interactive primitives provide keyboard and focus behavior. See the source for the complete typed API.
