Aspect Ratio

Display content at a fixed width-to-height ratio using Tailwind utilities.

Abstract geometric artwork

Usage

Use aspect-video for 16:9, aspect-square for 1:1, or aspect-[width/height] for another ratio. No Basecoat-specific class or JavaScript is needed.

<div class="aspect-video w-full max-w-sm overflow-hidden rounded-lg bg-muted">
  <img src="/photo.jpg" alt="Mountain landscape" class="h-full w-full object-cover" />
</div>

The wrapper sets the ratio; object-cover crops the image to fill it. Use object-contain to show the whole image instead. Unlike upstream, this is a CSS utility pattern rather than a wrapper component.

Examples

Square

Abstract geometric artwork

Portrait

Abstract geometric artwork

RTL

Use dir="rtl" for right-to-left content. The image ratio stays the same.

تصميم هندسي تجريدي
تصميم هندسي تجريدي