apps/www/content/docs/components/aspect-ratio.mdx
The ratio prop overrides the original aspect ratios of AspectRatio's child
content, accepting only numeric values, not strings.
import { AspectRatio } from "@chakra-ui/react"
<AspectRatio ratio={16 / 9}>
<iframe
title="naruto"
src="https://www.youtube.com/embed/QhBnZ6NPOY0"
allowFullScreen
/>
</AspectRatio>
Here's how to embed an image that has a 4 by 3 aspect ratio.
<ExampleTabs name="aspect-ratio-with-image" />Embed a video using an iframe, and use the ratio prop to override the video's
original aspect ratio.
Here's how to embed a responsive Google map using AspectRatio.
Here's an example of applying a responsive aspect ratio to a box.
<ExampleTabs name="aspect-ratio-responsive" />Chakra UI also provides
predefined aspect ratio tokens out of the box,
including square, landscape, portrait, wide, ultrawide, and golden
that can only be used in the aspectRatio CSS prop.
:::note
They cannot be used with the ratio prop that AspectRatio accepts.
:::
<Box aspectRatio="square" />
These props can be passed to the AspectRatio component.