max-w-fit: Tailwind CSS Width class

The rounded class applies small rounded corners to an element.


Max-w-fit

The max-w-fit class allows the element's width to shrink to fit its content.

Example Code

html
<div class="flex justify-center items-center gap-2 p-3 rounded-t-md bg-indigo-50">
<div class="max-w-fit bg-indigo-500 py-4 text-white font-bold rounded-lg px-4">
max-w-fit
</div>
</div>

Preview

max-w-fit

How to Use

Add the max-w-fit class directly to your HTML element:

html
<div class="max-w-fit">
<!-- Your content here -->
</div>

Responsive Usage

Use Tailwind's responsive prefixes to apply max-w-fit at specific breakpoints:

html
<div class="sm:max-w-fit md:max-w-fit lg:max-w-fit">
Responsive element
</div>
  • sm:max-w-fit — applies from 640px and up
  • md:max-w-fit — applies from 768px and up
  • lg:max-w-fit — applies from 1024px and up

Customization

You can extend or override this utility in your tailwind.config.js. See the Tailwind CSS documentation for details on customizing your theme.

Windframe is an AI visual editor for rapidly building stunning web UIs & websites

Start building stunning web UIs & websites!

Build from scratch or select prebuilt tailwind templates