Truncate

Truncated text for lit-material: end or middle ellipsis for long IDs, hashes, paths and URLs, full text kept for copy, search and screen readers.

  • 988 B gzipped
  • @lit-material/truncate 0.1.1
  • Renders on the server

Example

Install

npm install @lit-material/truncate @lit-material/tokens
import "@lit-material/truncate";

Link @lit-material/tokens/css/index.css once per page for the colour, type and shape tokens. Install guide

API

<lit-material-truncate>

One line of text that ends in an ellipsis when it doesn't fit — or, with position="middle", keeps its last characters so long IDs, hashes, paths and URLs stay recognisable at both ends: sha256:9f86d0…0f00a08.

Properties

PropertyAttributeTypeDefaultDescription
valuevaluestring""The full text.
positionpositionTruncatePosition"end"Where the ellipsis goes.
tailLengthtail-lengthnumber8With position="middle", how many characters to keep at the end.
truncatedtruncatedbooleanfalseSet while the text doesn't fit; reflected.

CSS parts

PartDescription
startThe part that shrinks (all of the text with position="end").
tailThe kept end with position="middle".

Source on GitHub npm