Truncate
Text on one line, cut with “…” where its box ends. While it is cut, a tooltip shows all of it.
<Truncate maxWidth={220} className="text-body-3"> production-us-east-claude-sonnet-5-5-primary-connection</Truncate>Installation
import { Truncate } from "@catalog-dashboard/components";Any text style
Truncate only cuts. It sets no size, no weight and no color: it takes them from its className, or from what holds it. The “…” takes the text's color. The tooltip keeps the Tooltip's own type and color.
production-us-east-claude-sonnet-5-5-primary-connection
<Truncate maxWidth={220} className="text-body-3 text-neutral-fg-secondary">production-us-east-claude-sonnet-5-5-primary-connection</Truncate><Truncate maxWidth={220} className="text-label-2 text-neutral-fg">production-us-east-claude-sonnet-5-5-primary-connection</Truncate><Truncate maxWidth={220} className="text-heading-5 text-neutral-fg">production-us-east-claude-sonnet-5-5-primary-connection</Truncate> <p className="text-body-mono-3 text-error-fg-secondary"> <Truncate maxWidth={220}>production-us-east-claude-sonnet-5-5-primary-connection</Truncate></p>Width
With no width set it is as wide as its text, up to the width of what holds it; past that it is cut. className="min-w-0 flex-1" takes what a row leaves it; className="block" fills a cell; maxWidth caps it, in px as a number or any CSS width as a string, and so does a max-w-* class. Either cap replaces the first one: a maxWidth wider than what holds it runs past it.
<div className="flex w-75 items-center gap-2 text-body-2"> <Truncate className="min-w-0 flex-1">production-us-east-claude-sonnet-5-5-primary-connection</Truncate> <Badge color="neutral" size="md">Default</Badge></div> <div className="w-75 text-body-2"> <Truncate className="block">production-us-east-claude-sonnet-5-5-primary-connection</Truncate></div> <Truncate maxWidth={160} className="text-body-2">production-us-east-claude-sonnet-5-5-primary-connection</Truncate><Truncate maxWidth="20ch" className="text-body-2">production-us-east-claude-sonnet-5-5-primary-connection</Truncate>Tooltip
Cut, it shows its whole text in the ds Tooltip, 200ms after the pointer rests on it (CUT_TEXT_TOOLTIP_DELAY). Text that fits shows none: it is measured when it mounts, when its text changes and when its box resizes. tooltip sets other text. tooltip={false} shows none: for text inside something that has a tooltip of its own, as a Badge with a tooltip does. side picks the side it opens on.
<Truncate maxWidth={160} className="text-body-2">production-us-east-claude-sonnet-5-5-primary-connection</Truncate><Truncate maxWidth={160} className="text-body-2">claude-haiku-5-5</Truncate><Truncate maxWidth={160} className="text-body-2" tooltip="The primary connection in us-east">production-us-east-claude-sonnet-5-5-primary-connection</Truncate><Truncate maxWidth={160} className="text-body-2" tooltip={false}>production-us-east-claude-sonnet-5-5-primary-connection</Truncate><Truncate maxWidth={160} className="text-body-2" side="bottom">production-us-east-claude-sonnet-5-5-primary-connection</Truncate>Accessibility
The whole text stays in the page; only the drawing is cut. Selecting and copying give the whole text. A screen reader should read all of it, since it is all in the page; this was not tested.
While it is cut it takes a tab stop of its own (tabIndex=0), with a focus ring, and the keyboard's focus there opens the tooltip at once. Text that fits, and text with tooltip={false}, takes none.
Inside a[href], button, or an element with the role button, link, option, menuitem, menuitemradio, menuitemcheckbox or tab, it takes no tab stop: a second stop there would be a control nested in a control. That element's own keyboard focus (:focus-visible) opens the tooltip, after the same 200ms. Inside anything else that takes focus, an element with only a tabindex for one, it keeps its own tab stop.
It never sets a native title, so there are never two tooltips. Its cursor is the one it inherits, never help.
API Reference
It draws a span, an inline-block with align-bottom, with data-slot="truncate", and data-truncated while the text is cut. Besides these, the props of a span, spread last: a caller's data-slot, tabIndex or style.maxWidth replaces its own. Pass no ref: it replaces the one the text is measured with, and the text is then never seen as cut, with no tooltip and no tab stop.
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | The text, whole. All of it stays in the page. |
tooltip | ReactNode | false | children | What the tooltip says while the text is cut. false shows none. |
maxWidth | number | string | — | The widest it may be: a number is px, a string any CSS width. Without it, the width of what holds it. With it, what holds it no longer caps it. |
side | "top" | "bottom" | "left" | "right" | "inline-start" | "inline-end" | "top" | The side of the text its tooltip opens on. |
className | string | — | Its type, its color and how it sits: any type role, any text color, block, min-w-0 flex-1, a max-w-*. |
Rules
Written down
It only cuts
Do: give it any type role and any text color in className, or let it take them from what holds it.
Don't: change truncate.tsx so that it sets a size, a weight or a color. Each use sets them.
From ds/components/truncate.tsx, and the designer (Nov 19).
Text that was only cut is Truncate, not a Hint
Text that is the same words, cut short, is Truncate. A Hint's tooltip says something its text does not.
From ds/components/hint.tsx.
Its tooltip waits 200ms
A tooltip that reveals cut text waits 200ms under the pointer. One on an icon, an icon button, the (i) or a status reason opens at once.
From .claude/rules/dashboard-ui.md and ds/components/truncate.tsx (CUT_TEXT_TOOLTIP_DELAY).
One line only
A clamp to several lines is not this component.
From ds/README.md (Truncate).
In a table, plain text is cut by the Table
The Table wraps a cell that returns a string or a number in Truncate, and TableLink wraps a child that is one string.
The Table does not wrap a cell that returns an element: its text is cut only if that element cuts it.
From .claude/rules/dashboard-ui.md (T17), ds/components/table/data-table.tsx and ds/components/table/cell.tsx.
In a table, a number or a date is never cut
Written with numberColumn, dateColumn or agoColumn, a number shortens (123,456 → 123.5K) and a date or a time ago shortens step by step (November 12th, 2026 → Nov 12, 26 → 11/12/26; 3 hours ago → 3h), never with “…”: its column is never narrower than its shortest whole form. Everything else is text, cut with “…”, a badge's word too.
From .claude/rules/dashboard-ui.md (T12).