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.

Use cases

  • Responsive images — maintain consistent aspect ratios across screen sizes.
  • Video embeds — prevent layout shift before the video loads.
  • Card thumbnails — uniform grid appearance in masonry or grid layouts.

When NOT to use

  • Fixed-size containers where the dimensions are known — use explicit width/height.
  • Text-only content that should grow to fit — AspectRatio constrains height, which clips overflow.

Common ratios

NameValueUse case
Square1Avatar, icon containers
4:34 / 3Classic photo/video
16:916 / 9Widescreen video, hero images
21:921 / 9Ultrawide banners

Composition

  • Child content fills the container. Use object-cover on images to crop, object-contain to letterbox.
  • Nest inside a Card for consistent thumbnail grids.
  • Combine with Skeleton as the child for a loading placeholder that preserves layout.
  • Card — often uses AspectRatio for thumbnails.
  • Avatar — always renders as a 1:1 circle/square.