Skip to Content

Built by moveinready.casa  and the community

Shadcn Docs

Radix Docs

Aspect Ratio

Displays content within a desired ratio.

Usage

import {Image} from "react-native"; import {AspectRatio} from "@/components/ui/aspect-ratio"; <AspectRatio ratio={16 / 9} className="bg-muted rounded-lg"> <Image source={{ uri: "https://images.unsplash.com/photo-1588345921523-c2dcdb7f1dcd?w=800&dpr=2&q=80", }} resizeMode="cover" className="h-full w-full" /> </AspectRatio>;

Props

PropTypeDefaultDescription
childrenReact.ReactNode-Required. The content to be constrained to the aspect ratio.
rationumber1 / 1Desired width/height ratio. A value of 16/9 represents a 16 × 9 ratio.
asChildbooleanfalseIf true clones the child and passes the aspect ratio style to it instead of rendering a wrapping View.
baseClassNamestring-Custom tailwind classes to apply to the base component. Takes priority over the className prop.

Also extends all React Native View component props.

shadcn-native

Built by moveinready.casa and the community