flex-shrink

Term side of the Card.
Topic: Flexboxes
Unit title: flex-shrink
Categories: Property
Explanation side of the Card

Explanation: The property that controls how much a flex item should shrink relative to the other flex items when there's not enough space in the flex container. It determines how an item reduces in size when the container is too small, helping to manage space distribution in tight layouts.

Browser compatibility:
  • The chrome browser supports this feature starting from version 29.
  • The edge browser supports this feature starting from version 12.
  • The firefox browser supports this feature starting from version 20.
  • The safari browser supports this feature starting from version 9.
Availability: 

Example

Wrongcss
.avatar {
  width: 40px;
}
Rightcss
.avatar {
  width: 40px;
  flex-shrink: 0;
}

flex-shrink: 0 keeps the avatar at 40px when the row runs out of space.

Common mistakes

  • An icon gets squished next to long text.
  • flex-shrink does nothing because the item's min-width: auto keeps it at content size.

Key points

  • Fixed-size items like icons and avatars set flex-shrink: 0.
  • Text items that should shrink also set min-width: 0 so long content can be truncated.

Interview questions

What is the default flex-shrink value?

It is 1, so every flex item can shrink when the container is too small.

Why won't my flex item shrink below its content?

Flex items have min-width: auto by default. Set min-width: 0 or overflow: hidden to let them shrink further.

Analytics cookiesWe'd like to use analytics cookies to see which pages are useful. They're set only if you accept. Privacy Policy