Quick reference

Class
Properties
max-w-0max-width: 0rem; /* 0px */
max-w-nonemax-width: none;
max-w-xsmax-width: 20rem; /* 320px */
max-w-smmax-width: 24rem; /* 384px */
max-w-mdmax-width: 28rem; /* 448px */
max-w-lgmax-width: 32rem; /* 512px */
max-w-xlmax-width: 36rem; /* 576px */
max-w-2xlmax-width: 42rem; /* 672px */
max-w-3xlmax-width: 48rem; /* 768px */
max-w-4xlmax-width: 56rem; /* 896px */
max-w-5xlmax-width: 64rem; /* 1024px */
max-w-6xlmax-width: 72rem; /* 1152px */
max-w-7xlmax-width: 80rem; /* 1280px */
max-w-fullmax-width: 100%;
max-w-minmax-width: min-content;
max-w-maxmax-width: max-content;
max-w-fitmax-width: fit-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;

Basic usage

Setting the maximum width

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

Andrew Alfred
Assistant to the Traveling Secretary
<div class="max-w-md ...">
  <!-- ... -->
</div>

Reading width

The max-w-prose utility gives an element a max-width optimized for readability and adapts based on the font size.

text-sm

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.

text-base

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.

text-xl

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>

Constraining to your breakpoints

The max-w-screen-{breakpoint} 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>

Applying conditionally

Hover, focus, and other states

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.

Breakpoints and media queries

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.


Using custom values

Customizing your theme

You can customize your max-width scale by editing theme.maxWidth or theme.extend.maxWidth in your tailwind.config.js file.

tailwind.config.js
module.exports = {
  theme: {
    extend: {
      maxWidth: {
        '1/2': '50%',
      }
    }
  }
}

Learn more about customizing the default theme in the theme customization documentation.

Arbitrary values

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-[50%]">
  <!-- ... -->
</div>

Learn more about arbitrary value support in the arbitrary values documentation.