Sizing
Utilities for setting the height of an element.
Use h-{number}
or h-px
to set an element to a fixed height.
<div class="h-96 ...">h-96</div>
<div class="h-80 ...">h-80</div>
<div class="h-64 ...">h-64</div>
<div class="h-48 ...">h-48</div>
<div class="h-40 ...">h-40</div>
<div class="h-32 ...">h-32</div>
<div class="h-24 ...">h-24</div>
Use h-full
to set an element’s height to 100% of its parent, as long as the parent has a defined height.
<div class="h-48">
<div class="h-full ...">
<!-- This element will have a height of `12rem` (h-48) -->
</div>
</div>
Use h-screen
to make an element span the entire height of the viewport.
<div class="h-screen">
<!-- ... -->
</div>
Use h-dvh
to make an element span the entire height of the viewport, which changes as the browser UI expands or contracts.
Scroll up and down in the viewport to hide/show the browser UI
<div class="h-dvh">
<!-- ... -->
</div>
Use h-lvh
to set an element’s height to the largest possible height of the viewport. This behaves the same as 100vh
.
Scroll up and down in the viewport to hide/show the browser UI
<div class="h-lvh">
<!-- ... -->
</div>
Use h-svh
to set an element’s height to the smallest possible height of the viewport.
Scroll up and down in the viewport to hide/show the browser UI
<div class="h-svh">
<!-- ... -->
</div>
Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:h-full
to only apply the h-full
utility on hover.
<div class="h-8 hover:h-full">
<!-- ... -->
</div>
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:h-full
to apply the h-full
utility at only medium screen sizes and above.
<div class="h-8 md:h-full">
<!-- ... -->
</div>
To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.
By default, Tailwind’s height scale is a combination of the default spacing scale as well as some additional values specific to heights.
You can customize your spacing scale by editing theme.spacing
or theme.extend.spacing
in your tailwind.config.js
file.
module.exports = {
theme: {
extend: {
spacing: {
'128': '32rem',
}
}
}
}
To customize height separately, use the theme.height
section of your tailwind.config.js
file.
module.exports = {
theme: {
extend: {
height: {
'128': '32rem',
}
}
}
}
Learn more about customizing the default theme in the theme customization documentation.
If you need to use a one-off 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="h-[32rem]">
<!-- ... -->
</div>
Learn more about arbitrary value support in the arbitrary values documentation.