- Published
Aspect Ration - Tailwind docs example
- Authors
- Name
- Tailwind Labs Team
Basic usage
Setting the aspect ratio
Use the aspect-{ratio} utilities to set the desired aspect ratio of an element.
_7<iframe_7 class="aspect-video w-full rounded-lg shadow-lg"_7 src="https://www.youtube.com/embed/dQw4w9WgXcQ"_7 frameborder="0"_7 allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"_7 allowfullscreen_7></iframe>
Tailwind doesn't include a large set of aspect ratio values out of the box since it's easier to just use arbitrary values. See the arbitrary values section for more information.
Browser support
The aspect-{ratio} utilities use the native aspect-ratio CSS property, which was not supported in Safari until version 15. Until Safari 15 is popularized, Tailwind's aspect-ratio plugin is a good alternative.
Applying conditionally
Hover, focus, and other states
Using custom values
Customizing your theme
By default, Tailwind provides a minimal set of aspect-ratio utilities. You can customize these values by editing theme.aspectRatio or theme.extend.aspectRatio in your tailwind.config.js file.