Max-Height
Utilities for setting the maximum height of an element.
Show all classes
Set the maximum height of an element using the or max-h-screen
utilities.
Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:max-h-screen
to only apply the max-h-screen
utility on hover.
<div class="h-48 max-h-full hover:max-h-screen">
<!-- ... -->
</div>
You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:max-h-screen
to apply the max-h-screen
utility at only medium screen sizes and above.
To learn more, check out the documentation on Responsive Design, and other media query modifiers.
By default, Tailwind’s max-height scale uses a combination of the as well as some additional height related values.
You can customize your spacing scale by editing or theme.extend.spacing
in your tailwind.config.js
file.
module.exports = {
theme: {
extend: {
'128': '32rem',
}
}
}
Alternatively, you can customize just the max-height scale by editing theme.maxHeight
or theme.extend.maxHeight
in your tailwind.config.js
file.
tailwind.config.js
Learn more about customizing the default theme in the theme customization documentation.
If you need to use a one-off max-height
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.
<div class="max-h-[32rem]">
<!-- ... -->