Browse documentation
Reference / Layout
Aspect ratio
Keep artwork, thumbnails or video placeholders in proportion as their available width changes.
Working example
Leave at least one dimension automatic. A fixed width and a fixed height already determine the shape.
<figure class="grid aspect-video w-full max-w-sm place-items-center bg-black text-white">
<figcaption class="font-mono">16 / 9</figcaption>
</figure>Class reference
| Class | CSS declarations |
|---|---|
aspect-square | aspect-ratio: 1 / 1; |
aspect-video | aspect-ratio: 16 / 9; |
aspect-4/3 | aspect-ratio: 4 / 3; |
aspect-[3/2] | aspect-ratio: 3/2; |
aspect-auto | aspect-ratio: auto; |
View full generated CSS
.aspect-4\/3 {
aspect-ratio: 4 / 3;
}
.aspect-\[3\/2\] {
aspect-ratio: 3/2;
}
.aspect-auto {
aspect-ratio: auto;
}
.aspect-square {
aspect-ratio: 1 / 1;
}
.aspect-video {
aspect-ratio: 16 / 9;
}