Knit UI
GitHub

Playground

Loading playground…

Playground
<AspectRatio
  ratio={1.7777777777777777}
>
  <Box flex={1} backgroundColor="$color5" alignItems="center" justifyContent="center">
    <Text>16 / 9</Text>
  </Box>
</AspectRatio>

Examples

Square

Square ratio (1 : 1) — the default when no ratio is provided.

Loading example…

SquareSourceStorybook

Widescreen

Classic 16 : 9 widescreen ratio, typical for video embeds.

Loading example…

WidescreenSourceStorybook

Portrait

Portrait 9 : 16 ratio, suitable for vertical media.

Loading example…

PortraitSourceStorybook

Common Ratios

Common ratios side by side for visual comparison.

Loading example…

Common RatiosSourceStorybook

Inside Flex Row

Inside a flex row — alignSelf: "stretch" fills the row's height and derives the width from the ratio, so the box keeps its proportions next to a flex sibling instead of forcing 100% width.

Loading example…

Inside Flex RowSourceStorybook

Overflow Clipped

Overflow clipping — the inner content is larger than the container and gets clipped.

Loading example…

Overflow ClippedSourceStorybook

With Image Placeholder

Renders an image-like placeholder scaled inside the ratio box.

Loading example…

With Image PlaceholderSourceStorybook

Props

PropTypeDefaultDescription
disabled systemboolean | undefined
shadow system"xs" | "sm" | "md" | "lg" | "xl" | "xxs" | "xxl" | undefined
theme systemThemeName | null | undefinedApplies a theme to this element
Accessibility & DOM props (2)
PropType
keyKey | null | undefined
refRef<TamaguiElement> | undefined

Plus 499 inherited style props from Box — the full Tamagui/React Native style surface, including token shorthands like p, mx, bg and c. See Tokens for the scales they accept, or the full list.