object-fit
Utilities for controlling how a replaced element’s content should be resized.
| Class | Effect |
|---|---|
object-contain |
object-fit: contain; |
object-cover |
object-fit: cover; |
object-fill |
object-fit: fill; |
object-none |
object-fit: none; |
object-scale-down |
object-fit: scale-down; |
Examples
Section titled “Examples”Resizing to cover
Section titled “Resizing to cover”Use object-cover to fill the box while keeping the image’s aspect ratio, cropping what does not fit.


ui.image(DEMO_IMAGE, "h-48 w-96 rounded-lg bg-gray-200 object-cover dark:bg-white/5")Containing within
Section titled “Containing within”

ui.image(DEMO_IMAGE, "h-48 w-96 rounded-lg bg-gray-200 object-contain dark:bg-white/5")Stretching to fit
Section titled “Stretching to fit”

ui.image(DEMO_IMAGE, "h-48 w-96 rounded-lg bg-gray-200 object-fill dark:bg-white/5")