You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Badge: full label should be reachable by focus and on touch, and only when it is actually clipped #5585
#5558 stops a long Badge label escaping its container by clipping it with an
ellipsis, and — per review — carries a string or number label in the badge's
native title so the tail is not simply lost.
title is deliberately the cheap half of that answer: it costs no measurement
and no hook, so Badge keeps rendering identically on the server. It leaves
three things unsolved.
Gaps
It is set whether or not the label fits. Knowing whether the text is
actually clipped requires measuring the rendered element, which title
avoids by design. A badge whose label fits comfortably still carries a
redundant tooltip.
It is pointer-only. A native title answers hover. It does not answer
keyboard focus, and on touch it does not appear at all — so the full text is
unreachable for anyone not using a mouse. This is the part of @rubyycheung's review that fix(Badge): a long label no longer escapes its container #5558 does not close.
A rich label gets nothing. A ReactNode label would have to be
flattened to a string, and flattening renders a guess — an icon, a <strong>, a nested element all read differently — so fix(Badge): a long label no longer escapes its container #5558 leaves it
alone.
What would close it
A tooltip shown only when the text is really cut:
measure the label (scrollWidth > clientWidth, or a ResizeObserver) and
attach the affordance only when it overflows;
reachable by hover and keyboard focus, which means the badge needs to be
focusable when — and only when — it carries recoverable text;
a touch path, since neither title nor hover exists there;
keep the title fallback for the server-rendered pass so the text is never
unreachable before hydration.
That is a client component, which is why #5558 does not do it: it is a real
trade-off (every Badge on a page becomes a client boundary, or the tooltip
becomes opt-in) and deserves its own discussion rather than riding along with a
containment fix.
Not blocking
Badge is not interactive today, so making it focusable is a behaviour change,
not just an addition — that is the first thing to settle.
A data point from a production app, on @astryxdesign/[email protected], in case it helps settle the trade-off.
Where we hit it. We use status Badges in dense tables and cards: order status, quote countdown, payment status and support ticket status. At 320–375 px, and in narrow table columns at 1440 px, the label was clipped with an ellipsis. The cuts we measured were between 4 px and 84 px. Our labels are in Portuguese, so a label such as "Pedido aceito — aguardando sinal" is long. The title gave mouse users the full label. Keyboard and touch users had no way to read it, which is gap 2 in this issue.
What we did instead of a tooltip. For a status label, we decided that the full text must always be visible, and that a tooltip is not enough. So we let those Badges wrap through style:
We also make the column wide enough that a one-word status never breaks inside the word at 100 % text. This works, but it overrides the Badge's own height and white-space rules from the outside.
A suggestion for the API discussion. One option to consider beside the clip-aware tooltip is an opt-in wrap mode on Badge, for example textWrap="wrap" or maxLines. It needs no client boundary and no focusability change, and it keeps the label readable for every input method. The tooltip would then serve the cases where the layout must stay one line.
Activity
fix(Badge): a long label no longer escapes its container (#5558)
suleimanmahmoud commentedon Nov 9, 2026
A data point from a production app, on
@astryxdesign/[email protected], in case it helps settle the trade-off.Where we hit it. We use status
Badges in dense tables and cards: order status, quote countdown, payment status and support ticket status. At 320–375 px, and in narrow table columns at 1440 px, the label was clipped with an ellipsis. The cuts we measured were between 4 px and 84 px. Our labels are in Portuguese, so a label such as "Pedido aceito — aguardando sinal" is long. Thetitlegave mouse users the full label. Keyboard and touch users had no way to read it, which is gap 2 in this issue.What we did instead of a tooltip. For a status label, we decided that the full text must always be visible, and that a tooltip is not enough. So we let those Badges wrap through
style:We also make the column wide enough that a one-word status never breaks inside the word at 100 % text. This works, but it overrides the Badge's own height and
white-spacerules from the outside.A suggestion for the API discussion. One option to consider beside the clip-aware tooltip is an opt-in wrap mode on
Badge, for exampletextWrap="wrap"ormaxLines. It needs no client boundary and no focusability change, and it keeps the label readable for every input method. The tooltip would then serve the cases where the layout must stay one line.