Overview
AspectRatio maintains a consistent width-to-height ratio for its children, commonly used for responsive images, videos, and embedded content. It ensures content scales proportionally without distortion.Import
Props
Aspect ratio as width/height. Common values:
1: Square (1:1)16/9: Widescreen (16:9)4/3: Standard (4:3)21/9: Ultrawide (21:9)3/2: Photo (3:2)
Usage
Basic image
Square ratio
Video embed
Map embed
With overlay
Layout Examples
Image gallery
Product card
Blog post preview
Video playlist
Hero section
Avatar with aspect ratio
Testimonial card
Loading placeholder
Common Aspect Ratios
- 1:1 (
ratio={1}): Square - Avatars, Instagram posts - 16:9 (
ratio={16/9}): Widescreen - YouTube videos, modern displays - 4:3 (
ratio={4/3}): Standard - Classic photos, presentations - 21:9 (
ratio={21/9}): Ultrawide - Cinematic content, hero sections - 3:2 (
ratio={3/2}): Photography - DSLR standard - 9:16 (
ratio={9/16}): Vertical - Stories, mobile video
Best Practices
- Always use
object-coverorobject-containon images to control scaling - Use
rounded-lgor similar classes on AspectRatio for rounded corners - Combine with
SimpleGridfor consistent gallery layouts - Add loading placeholders with matching aspect ratios
- Use absolute positioning for overlays (buttons, badges, gradients)
- Set a max-width on the container to control the final size
- Test with different content to ensure proper cropping
- Consider using different ratios for mobile vs desktop with responsive classes