Sizing
Utilities for setting the maximum width of an element.
Set the maximum width of an element using the max-w-*
utilities.
<div>
<div class="w-full max-w-96 ...">max-w-96</div>
<div class="w-full max-w-80 ...">max-w-80</div>
<div class="w-full max-w-64 ...">max-w-64</div>
<div class="w-full max-w-48 ...">max-w-48</div>
<div class="w-full max-w-40 ...">max-w-40</div>
<div class="w-full max-w-32 ...">max-w-32</div>
<div class="w-full max-w-24 ...">max-w-24</div>
</div>
Above 24rem
, the max-w-*
utilities use a named scale instead of a numeric scale to make the values easier to guess.
<div class="max-w-md ...">
<!-- ... -->
</div>
The max-w-prose
utility gives an element a max-width optimized for readability and adapts based on the font size.
Oh yeah. It's the best part. It's crunchy, it's explosive, it's where the muffin breaks free of the pan and sort of does it's own thing. I'll tell you. That's a million dollar idea right there. Just sell the tops.
Oh yeah. It's the best part. It's crunchy, it's explosive, it's where the muffin breaks free of the pan and sort of does it's own thing. I'll tell you. That's a million dollar idea right there. Just sell the tops.
Oh yeah. It's the best part. It's crunchy, it's explosive, it's where the muffin breaks free of the pan and sort of does it's own thing. I'll tell you. That's a million dollar idea right there. Just sell the tops.
<div class="text-sm max-w-prose ...">
<p>Oh yeah. It's the best part. It's crunchy, it's explosive, it's where the muffin breaks free of the pan and sort of does it's own thing. I'll tell you. That's a million dollar idea right there. Just sell the tops.</p>
</div>
<div class="text-base max-w-prose ...">
<p>Oh yeah. It's the best part. It's crunchy, it's explosive, it's where the muffin breaks free of the pan and sort of does it's own thing. I'll tell you. That's a million dollar idea right there. Just sell the tops.</p>
</div>
<div class="text-xl max-w-prose ...">
<p>Oh yeah. It's the best part. It's crunchy, it's explosive, it's where the muffin breaks free of the pan and sort of does it's own thing. I'll tell you. That's a million dollar idea right there. Just sell the tops.</p>
</div>
The max-w-screen-*
classes can be used to give an element a max-width matching a specific breakpoint. These values are automatically derived from the theme.screens
section of your tailwind.config.js
file.
<div class="max-w-screen-2xl">
<!-- ... -->
</div>
Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:max-w-lg
to only apply the max-w-lg
utility on hover.
<div class="max-w-sm hover:max-w-lg">
<!-- ... -->
</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:max-w-lg
to apply the max-w-lg
utility at only medium screen sizes and above.
<div class="max-w-sm md:max-w-lg">
<!-- ... -->
</div>
To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.
By default, Tailwind’s maximum width scale is a combination of the default spacing scale as well as some additional values specific to widths.
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 max-width
separately, use the theme.maxWidth
section of your tailwind.config.js
file.
module.exports = {
theme: {
extend: {
maxWidth: {
'128': '32rem',
}
}
}
}
If you need to use a one-off max-width
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-w-[220px]">
<!-- ... -->
</div>
Learn more about arbitrary value support in the arbitrary values documentation.