Skip to content

Ellipsis

Automatically truncates long text with single-line / multi-line clipping; on overflow it shows the full text in a tooltip on hover, and it can also expand / collapse.

Single-Line Ellipsis

Single-line ellipsis

Constraining the width on the container is enough to trigger the ellipsis; when there is no overflow it renders plain text (without any overlay).

Multi-Line Ellipsis

Multi-line ellipsis (rows)

From rows="2" on, -webkit-line-clamp is used; on multi-line ellipsis the tooltip shows the full text.

Expand / Collapse

Expand / collapse

With expandable, the button only appears when the text actually overflows; once expanded, no ellipsis is applied, and the oas-expand / oas-collapse events can track the state.

Disabling the Tooltip

Tooltip disabled

API

Attributes

AttributeDescriptionTypeDefault
expandableShow an "expand/collapse" button when overflowingboolean
rowsNumber of lines to show (1 is single-line ellipsis, ≥2 multi-line -webkit-line-clamp)string1
textText contentstring
tooltipShow a full-text tooltip on hover when overflowingstringtrue

Events

EventDescription
oas-collapseCollapsed, detail: { expanded: false }
oas-expandExpanded, detail: { expanded: true }

The tooltip / expand button is only mounted when the text actually overflows; with no overflow it is plain text, and on disconnect it is destroyed — no orphaned overlays.