Tailwind CSS on GitHub

Max-Width

Utilities for setting the maximum width of an element

Default class reference

Class
Properties
max-w-0max-width: 0rem;
max-w-nonemax-width: none;
max-w-xsmax-width: 20rem;
max-w-smmax-width: 24rem;
max-w-mdmax-width: 28rem;
max-w-lgmax-width: 32rem;
max-w-xlmax-width: 36rem;
max-w-2xlmax-width: 42rem;
max-w-3xlmax-width: 48rem;
max-w-4xlmax-width: 56rem;
max-w-5xlmax-width: 64rem;
max-w-6xlmax-width: 72rem;
max-w-7xlmax-width: 80rem;
max-w-fullmax-width: 100%;
max-w-minmax-width: min-content;
max-w-maxmax-width: max-content;
max-w-prosemax-width: 65ch;
max-w-screen-smmax-width: 640px;
max-w-screen-mdmax-width: 768px;
max-w-screen-lgmax-width: 1024px;
max-w-screen-xlmax-width: 1280px;
max-w-screen-2xlmax-width: 1536px;

Usage

Set the maximum width of an element using the max-w-{size} utilities.

max-w-md
<div class="max-w-md mx-auto ...">
  max-w-md
</div>

Prose

We added a new max-width by default called max-w-prose. If you are familiar with the typography plugin you might recognize this one. The idea behind this class is that it allows you to have an optimal reading width.

Why do you never see elephants hiding in trees?

Because they're so good at it. Lorem ipsum dolor sit amet consectetur adipisicing elit. Quas cupiditate laboriosam fugiat.

<div class="max-w-prose ...">
  <p class="font-bold">Why do you never see elephants hiding in trees?</p>
  <p>Because they're so good at it. Lorem ipsum dolor sit amet consectetur adipisicing elit. Quas cupiditate laboriosam fugiat.</p>
</div>

Responsive

To control the max-width of an element at a specific breakpoint, add a {screen}: prefix to any existing max-width utility.

<div class="max-w-sm md:max-w-lg ...">
  <!-- ... -->
</div>

For more information about Tailwind's responsive design features, check out the Responsive Design documentation.


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.

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: {
      extend: {
        // ...
+       maxWidth: ['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,
    }
  }