Components · Layout
Aspect Ratio
StableAdded v0.0.1
Keeps its content at a fixed width-to-height ratio, for images, video and embeds.
import { AspectRatio } from '@nexub/react';Examples
Image
Ratios
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| ratio | number | 16 / 9 | Width divided by height, e.g. 16 / 9 or 1. Common ratios (1, 16/9, 4/3, 3/2, 21/9, 9/16, 3/4, 2/3) use a class and are strict-CSP safe; any other ratio sets an inline aspect-ratio style. |
| children | ReactNode | — | Fills the box; give an image h-full w-full object-cover. |
On iOS & Android
Web only
Aspect Ratio has no @nexub/react-native twin. On phones, follow the platform pattern instead, or compose it from the native components listed on the React Native page.