Web Development 4 min read Practical Guide

Flexbox Text Overflow on Mobile? Fix It With min-width: 0

Ukasha Mart Editorial

Software Developer & Digital Tools Creator

Published: 2026-11-18
Flexbox Text Overflow on Mobile? Fix It With min-width: 0

At a glance

Put min-width: 0 on the direct flex child that holds the text. Use overflow-wrap: anywhere when readers need to see the whole value, or use white-space: nowrap, overflow: hidden, and text-overflow: ellipsis on the label for a single line.

A download row fits on desktop. On a phone, a long export filename pushes the Download button past the right edge. You set flex: 1 on the text column, but the row still overflows. That usually means the flex child has reached its automatic minimum width before it has become narrow enough to fit.

Fix the flex item before styling the text

Try this file row in a browser. The 16-rem width makes the bug easy to see without resizing the window.

<div class="file-row">
  <div class="file-info">
    <p class="file-name">november_export_customer_orders_europe_2026.csv</p>
    <small>CSV export</small>
  </div>
  <button type="button">Download</button>
</div>
.file-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 16rem;
  max-width: 100%;
}

.file-info {
  flex: 1;
  min-width: 0;
}

.file-name {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-row > button {
  flex: none;
}

Toggle min-width: 0 off in DevTools. The label is styled to show an ellipsis, but its parent can still use the whole filename to decide how narrow the column may be. Turn the rule back on. The browser can now shrink .file-info, the ellipsis has a constrained box to work in, and the button keeps its width. In Tailwind, use min-w-0 on the flex child and truncate on the text.

Keep the whole filename when it matters

If a reader needs to distinguish similar export names by their suffixes, wrapping can be easier to use. Replace the ellipsis rules on .file-name with:

.file-name {
  margin: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

Long URLs and filenames gain break opportunities where there are no spaces. The row may grow taller, so check alignment with the button. If you choose truncation for a dense list, keep the full name available in a file details view or another place reachable by touch and keyboard.

If the page still scrolls sideways

Inspect the box that extends past the row. In this example, .file-info is the direct flex child. Adding min-width: 0 to .file-name alone leaves the parent's minimum intact. If the row sits inside another flex layout, inspect the next flex item up as well. Also check for a fixed-width image or input that is wider than the space you have left.

Avoid hiding the symptom with a page-wide overflow rule. That can cut off controls and affect sticky headers or sidebars.

Verify the fix

  • Try a normal label, a long string with no spaces, and a long label with a short distinguishing suffix.
  • At 320 CSS pixels and with browser zoom, check that the button stays visible and that keyboard focus can reach it.
  • For wrapping, confirm the row can grow vertically. For an ellipsis, confirm that the full filename remains available where readers need it.

References

Relevant Free Tool

Try our QR Code Generator

Create clean, scannable QR codes for testing websites, URLs, and client handoffs.

Launch Tool
Ukasha Mart Editorial
Written by

Ukasha Mart Editorial

Software Developer & Digital Tools Creator

Founder of Ukasha Mart. Building free, accessible browser-based utilities and writing in-depth tutorials on modern technology, freelancing, and practical online work.

Chat on WhatsApp