Max-Width
Utilities for setting the maximum width of an element
Usage
Set the maximum width of an element using the max-w-{size} utilities.
<div class="max-w-md mx-auto ...">
max-w-md
</div>Responsive
To control the max-width of an element at a specific breakpoint, add a {screen}: prefix to any existing max-width utility.
For more information about Tailwind's responsive design features, check out the Responsive Design documentation.
<div class="max-w-sm sm:max-w-md md:max-w-lg lg:max-w-xl xl:max-w-2xl ...">
Target
</div>Customizing
Max-Width Scale
Customize Tailwind's default max-width scale in the theme.maxWidth section of your tailwind.config.js file.
// tailwind.config.js
module.exports = {
theme: {
maxWidth: {
+ '1/4': '25%',
+ '1/2': '50%',
+ '3/4': '75%',
}
}
}Learn more about customizing the default theme in the theme customization documentation.
Responsive and pseudo-class variants
By default, only responsive variants are generated for max-width utilities.
You can control which variants are generated for the max-width utilities by modifying the maxWidth property in the variants section of your tailwind.config.js file.
For example, this config will also generate hover and focus variants:
// tailwind.config.js
module.exports = {
variants: {
// ...
- maxWidth: ['responsive'],
+ maxWidth: ['responsive', 'hover', 'focus'],
}
}Disabling
If you don't plan to use the max-width utilities in your project, you can disable them entirely by setting the maxWidth property to false in the corePlugins section of your config file:
// tailwind.config.js
module.exports = {
corePlugins: {
// ...
+ maxWidth: false,
}
}