MiHCM
layout/@mihcm/ui·v0.21.0·stable

AspectRatio

Locks a container to a given width-to-height ratio. Uses CSS aspect-ratio on web and RN aspectRatio style on native.

Live preview

Adjust the controls on the right; the preview and code update in real time.

16/9
example.tsxtsx
import { AspectRatio } from '@mihcm/ui/AspectRatio';

export function Example() {
  return (
    <AspectRatio
  ratio="16/9"
    ></AspectRatio>
  );
}

Install

Both paths are valid. CLI ships the source into your repo (you own it). Install pins via npm.

npx @mihcm/cli add AspectRatio
Copies the source into components/ds/AspectRatio.tsx. You own the file. Use --out to override the directory or --force to overwrite.