Truncate

Text that clips with an ellipsis and shows its full value in a quick tooltip on hover, only while it's actually clipped. It's the rule across the system: every truncated value goes through Truncate, and lint rejects a bare truncate or line-clamp class.

BetaReady to use. Its API can still change in a minor release; the changelog says when.

import { Truncate } from "@leap-crm/design-system";

Playground

Change a prop and the component follows. Its code is under Props.

Hartley Okafor Moreau Family Trust

Props

lines
inline
side
align

Best practices

When to use it, and the rules that apply in particular places.

GuidancePractice
DoWrap every value that can be cut off, like a matter name in a table cell or an email in a header, so the whole value shows in a tooltip while it is clipped.
DoGive the parent a width or min-w-0 in a flex row, so the value has an edge to truncate against.
DoUse lines for a description that may wrap, so it keeps two or three lines before the ellipsis.
Don'tUse a bare truncate, line-clamp-* or text-ellipsis class. The reader loses the rest of the value, and lint rejects it.
Don'tTruncate a value the reader must act on in full, like an amount or a matter number. Give it the room instead.

Props

PropTypeDefaultDescription
children *ReactNode—The text. It clips with an ellipsis when it doesn't fit.
valueReactNode—The full value for the tooltip, when children isn't plain text. Defaults to children.
lines1 | 2 | 31How many lines before it clips.
inlinebooleanfalseA span for inside a line of text; a div otherwise.
side"top" | "right" | "bottom" | "left""top"Which side it opens on. It flips to the other when there isn't room.
align"start" | "center" | "end""start"How it lines up along that side: start, center or end.
classNamestring—Classes added to the root element, merged with its own. Tokens only.

Code

What the playground shows, ready to copy.

import { Truncate } from "@leap-crm/design-system";

<Truncate>Hartley Okafor Moreau Family Trust</Truncate>