CSS flex-shrink Property

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The flex-shrink property sets a flex item’s shrink factor — how much it should give up main-axis size when items are too wide (or tall) for the container.

The initial value is 1 (items may shrink). Use 0 to refuse shrinking. It applies only to flex items inside a display: flex container. It is not inherited. MDN recommends the flex shorthand for everyday grow + shrink + basis patterns.

Baseline widely available.

Not deprecated. Prefer non-negative numbers. Negatives are invalid. Shrinking is weighted by base size so tiny items are less likely to collapse to zero before larger ones shrink.

CSS Syntax

syntax.css
flex-shrink: <number> | initial | inherit;

One non-negative number. Examples: 0, 1, 2, 0.5.

Property Values

ValueDescriptionTry it
0Do not shrink. Keeps the item’s base sizeTry it
1May shrink. Initial value; equal share when siblings also use 1Try it
2Gives up more of the shortage than an item with 1Try it
<number>Any non-negative number used as a shrink ratioTry it
initialResets to 1Try it
inheritInherits from the parent elementTry it

How to Use flex-shrink

Create overflow pressure on the main axis, then decide which items give way.

  1. Set the parent to display: flex with a limited width (or height).
  2. Give items a large flex-basis or width so they want more space than the container has.
  3. Set flex-shrink on items that should compress (1 is default; 0 locks size).
  4. Pair with flex-grow or use the flex shorthand for complete control.
PieceRequired?Role
Flex containerYesParent must be display: flex or inline-flex
Negative free spaceYes (to see shrinking)Items’ base sizes larger than the container
Shrink factorYesRatio for how much each item gives up
flex-basis / widthMattersStarting size before shrink is applied

Live Preview

A narrow row holds three wide items. Only item A’s flex-shrink changes.

Each item starts near 8rem wide inside a tight row. Higher shrink on A makes A give up more space.

Tight flex row

A flex-shrink: 1

CSS Examples

Each snippet focuses on flex-shrink. A fixed container width creates the squeeze. Use Try It Yourself for a live editor.

Example 1 — Default Shrink

With flex-shrink: 1, wide items compress to fit the row.

CSS
<style>
  .row {
    display: flex;
    width: 280px;
  }

  .item {
    flex-basis: 150px;
    flex-shrink: 1;
  }
</style>

<div class="row">
  <div class="item">A</div>
  <div class="item">B</div>
</div>
Try It Yourself

How It Works

  1. Limit the row. width: 280px is smaller than two 150px bases.
  2. Set a large basis. Each item wants 150px before shrinking.
  3. Allow shrink. flex-shrink: 1 (the default) lets both items share the shortage.
  4. No overflow. The row stays within 280px because items give up space.

Example 2 — Refuse to Shrink

Lock one item with flex-shrink: 0 so others take the squeeze.

CSS
<style>
  .row {
    display: flex;
    width: 280px;
  }

  .a {
    flex-basis: 150px;
    flex-shrink: 0;
  }

  .b {
    flex-basis: 150px;
    flex-shrink: 1;
  }
</style>

<div class="row">
  <div class="a">A (0)</div>
  <div class="b">B (1)</div>
</div>
Try It Yourself

How It Works

  1. Same tight row. Two 150px bases still exceed 280px.
  2. Lock A. flex-shrink: 0 keeps A near its basis.
  3. B absorbs more. With shrink 1, B gives up most of the shortage.
  4. Common use. Icons or labels often use 0 so text fields shrink instead.

Example 3 — Unequal Shrink

A higher factor makes that item give up more of the shortage.

CSS
<style>
  .row {
    display: flex;
    width: 280px;
  }

  .a {
    flex-basis: 150px;
    flex-shrink: 1;
  }

  .b {
    flex-basis: 150px;
    flex-shrink: 2;
  }
</style>

<div class="row">
  <div class="a">A (1)</div>
  <div class="b">B (2)</div>
</div>
Try It Yourself

How It Works

  1. Create a shortage. Bases still exceed the 280px row.
  2. Compare factors. B at 2 gives up more of the negative space than A at 1.
  3. Base size still matters. Shrink is weighted so large items do not ignore tiny ones completely.
  4. Opposite of grow. flex-grow shares leftover space; shrink shares a shortage.

Edge Cases & Pitfalls

If items never shrink (or always overflow), check these points.

parent

Needs a flex container

flex-shrink only applies to flex items. Set display: flex on the parent first.

space

No shortage, no shrink

If items already fit, shrink factors do nothing visible. Use a smaller container or larger flex-basis to study the effect.

min

min-width can block shrinking

Default min-width: auto can stop an item from getting smaller than its content. Use min-width: 0 when text should compress inside flex layouts.

minus

Negatives are invalid

flex-shrink: -1 is dropped. Use 0 or a positive number.

grow

Shrink is not grow

When there is leftover space, flex-grow applies. When there is a shortage, flex-shrink applies.

Browser Support

flex-shrink is a browser CSS property for Flexbox. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available

flex-shrink

Supported in all modern browsers as part of CSS Flexible Box Layout (Baseline since September 2015).

100% Non-negative numbers
Google Chrome 29+
Full support
Mozilla Firefox 20+
Full support
Apple Safari 9+
Full support
Microsoft Edge 12+
Full support
Opera 17+
Full support
Samsung Internet All versions
Full support
Internet Explorer 11
Full support
flex-shrink Widely supported

Bottom line: Safe for production Flexbox layouts. Prefer the flex shorthand for common patterns. It is not a runtime API.

Key Takeaways

  • Role: decide how flex items share a shortage of main-axis space.
  • Initial value: 1. Not inherited.
  • Lock size: flex-shrink: 0 prevents shrinking.
  • Tip: use the flex shorthand when you also set grow and basis.

One line: flex-shrink is the ratio for giving up space when flex items are too big — 0 refuses, 1 shares the squeeze.

Frequently Asked Questions

It sets how much a flex item should shrink relative to its siblings when their base sizes are too large for the flex container.
The initial value is 1, so flex items can shrink by default when space is tight.
Set flex-shrink: 0. That item keeps its base size and other items (or overflow) absorb the squeeze.
It gives up about twice as much of the negative free space as an item with 1, weighted by base size — not simply half the final width.
MDN recommends flex for common patterns because it also sets flex-grow and flex-basis. Use flex-shrink alone when you need precise control.
It is Baseline and widely available in modern browsers. It is a browser CSS property, not a Node.js feature.

Next: flex-wrap

Learn how flex items can wrap onto new lines when space runs out.

flex-wrap tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful