Layout
Utilities for controlling how a replaced element's content should be positioned within its container.
Use the object-*
utilities to specify how a replaced element’s content should be positioned within its container.
object-left-top
object-top
object-right-top
object-left
object-center
object-right
object-left-bottom
object-bottom
object-right-bottom
<img class="object-none object-left-top bg-yellow-300 w-24 h-24 ..." src="...">
<img class="object-none object-top bg-yellow-300 w-24 h-24 ..." src="...">
<img class="object-none object-right-top bg-yellow-300 w-24 h-24 ..." src="...">
<img class="object-none object-left bg-yellow-300 w-24 h-24 ..." src="...">
<img class="object-none object-center bg-yellow-300 w-24 h-24 ..." src="...">
<img class="object-none object-right bg-yellow-300 w-24 h-24 ..." src="...">
<img class="object-none object-left-bottom bg-yellow-300 w-24 h-24 ..." src="...">
<img class="object-none object-bottom bg-yellow-300 w-24 h-24 ..." src="...">
<img class="object-none object-right-bottom bg-yellow-300 w-24 h-24 ..." src="...">
Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:object-top
to only apply the object-top
utility on hover.
<img class="object-center hover:object-top" src="...">
For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.
You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:object-top
to apply the object-top
utility at only medium screen sizes and above.
<img class="object-center md:object-top" src="...">
To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.
By default, Tailwind provides nine object position utilities. You can customize these values by editing theme.objectPosition
or theme.extend.objectPosition
in your tailwind.config.js
file.
module.exports = {
theme: {
extend: {
objectPosition: {
'center-bottom': 'center bottom',
}
},
}
}
Learn more about customizing the default theme in the theme customization documentation.
If you need to use a one-off object-position
value that doesn’t make sense to include in your theme, use square brackets to generate a property on the fly using any arbitrary value.
<img class="object-[center_bottom]" src="...">
Learn more about arbitrary value support in the arbitrary values documentation.