ZUI

Search documentation

Find a page or a heading.

Aspect ratio

A frame whose height follows its width at a given ratio.

Installation

bash

The CLI writes components/ui/aspect-ratio.tsx, installs Utils, and adds @rn-primitives/aspect-ratio.

Usage

tsx
tsx

API reference

AspectRatio

Takes every prop of the @rn-primitives/aspect-ratio root, plus:

ratio is width over height. The frame is as wide as its parent lets it be, and its height follows. A child sized size-full or absolute inset-0 fills it.

Differences from upstream

  • Upstream passes the ratio to CSS as a custom property. The native frame takes React Native's own aspectRatio style, which both engines draw.