On this page

InstallationAny text styleWidthTooltipAccessibilityAPI ReferenceRulesWritten down

Truncate

Text on one line, cut with “…” where its box ends. While it is cut, a tooltip shows all of it.

production-us-east-claude-sonnet-5-5-primary-connection
1<Truncate maxWidth={220} className="text-body-3">2  production-us-east-claude-sonnet-5-5-primary-connection3</Truncate>

Installation

text
import { Truncate } from "@dome-systems/ds-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-connectionproduction-us-east-claude-sonnet-5-5-primary-connectionproduction-us-east-claude-sonnet-5-5-primary-connection

production-us-east-claude-sonnet-5-5-primary-connection

1<Truncate maxWidth={220} className="text-body-3 text-neutral-fg-secondary">production-us-east-claude-sonnet-5-5-primary-connection</Truncate>2<Truncate maxWidth={220} className="text-label-2 text-neutral-fg">production-us-east-claude-sonnet-5-5-primary-connection</Truncate>3<Truncate maxWidth={220} className="text-heading-5 text-neutral-fg">production-us-east-claude-sonnet-5-5-primary-connection</Truncate>4
5<p className="text-body-mono-3 text-error-fg-secondary">6  <Truncate maxWidth={220}>production-us-east-claude-sonnet-5-5-primary-connection</Truncate>7</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.

production-us-east-claude-sonnet-5-5-primary-connectionDefault
production-us-east-claude-sonnet-5-5-primary-connection
production-us-east-claude-sonnet-5-5-primary-connectionproduction-us-east-claude-sonnet-5-5-primary-connection
1<div className="flex w-75 items-center gap-2 text-body-2">2  <Truncate className="min-w-0 flex-1">production-us-east-claude-sonnet-5-5-primary-connection</Truncate>3  <Badge color="neutral" size="md">Default</Badge>4</div>5
6<div className="w-75 text-body-2">7  <Truncate className="block">production-us-east-claude-sonnet-5-5-primary-connection</Truncate>8</div>9
10<Truncate maxWidth={160} className="text-body-2">production-us-east-claude-sonnet-5-5-primary-connection</Truncate>11<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.

production-us-east-claude-sonnet-5-5-primary-connectionclaude-haiku-5-5production-us-east-claude-sonnet-5-5-primary-connectionproduction-us-east-claude-sonnet-5-5-primary-connectionproduction-us-east-claude-sonnet-5-5-primary-connection
1<Truncate maxWidth={160} className="text-body-2">production-us-east-claude-sonnet-5-5-primary-connection</Truncate>2<Truncate maxWidth={160} className="text-body-2">claude-haiku-5-5</Truncate>3<Truncate maxWidth={160} className="text-body-2" tooltip="The primary connection in us-east">production-us-east-claude-sonnet-5-5-primary-connection</Truncate>4<Truncate maxWidth={160} className="text-body-2" tooltip={false}>production-us-east-claude-sonnet-5-5-primary-connection</Truncate>5<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.

PropTypeDefaultDescription
childrenReactNode—The text, whole. All of it stays in the page.
tooltipReactNode | falsechildrenWhat the tooltip says while the text is cut. false shows none.
maxWidthnumber | 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.
classNamestring—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).

compliance-evidence-collector
DoThe whole text is in the page and in the tooltip, and nothing is drawn under it.
compliance-evid…
Don’tThe dotted line promises something new, but the tooltip only shows the same text, whole.

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).