flex-shrink: Tailwind CSS Flex class

The my-2 class adds a margin of 0.5rem (8px) to the top and bottom sides of an element.


Flex Shrink

The flex-shrink class allows an element to shrink when the container has insufficient space.

Example Code

html
<div class="flex items-center justify-center space-x-5 p-5">
<div class="bg-blue-200 text-white font-bold p-4 rounded">Flex-none</div>
<div class="flex-shrink bg-blue-500 p-4 text-white font-bold rounded">flex-shrink</div>
<div class="bg-blue-200 text-white font-bold p-4 rounded">Flex-none</div>
</div>

Preview

Flex-none
flex-shrink
Flex-none

How to Use

Add the flex-shrink class directly to your HTML element:

html
<div class="flex-shrink">
<!-- Your content here -->
</div>

Responsive Usage

Use Tailwind's responsive prefixes to apply flex-shrink at specific breakpoints:

html
<div class="sm:flex-shrink md:flex-shrink lg:flex-shrink">
Responsive element
</div>
  • sm:flex-shrink — applies from 640px and up
  • md:flex-shrink — applies from 768px and up
  • lg:flex-shrink — 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