How to keep a leading icon from shrinking in a flex row
Answer in brief
Set flex-shrink: 0 on the icon or its wrapper when a fixed-size graphic shares a narrow row with variable text.
Stress-test a file list
Place a 24-pixel folder beside a long filename. Reduce the viewport until the label wraps. Confirm the folder stays 24 pixels wide and define wrapping or overflow behavior for the text column.
Let a long label give up space
A flex item containing an unbroken filename can retain a large minimum width. Allow the text item to shrink with min-width: 0, then choose wrapping or truncation for the filename itself. Inspect both items' final widths to confirm the folder remains fixed while the label absorbs the shortage.
Sources
- [1] flex-shrink CSS property - CSS — MDN Web Docs, accessed November 23, 2026
Frequently asked questions
Which element gets the shrink rule?
Apply it to the direct flex item. If a span wraps the image, sizing only the image can leave a narrower wrapper in the layout.