Skip to content
API 风格:

Ellipsis ​

Text truncation: multi-line CSS line-clamp is preferred (the line count is driven by the --lh-ellipsis-rows CSS variable); middle truncation goes through a JS cut (truncateMiddle, consistent across all platforms). Serves the "expandable / collapsible, middle truncation, custom action" scenarios (for plain truncation, keep using the ellipsis of the Text component). All truncation and state math consumes the pure logic in @lh-ui/share/core/ellipsis.

Basic Usage ​

Single-line / multi-line truncation (CSS line-clamp)
lh-ui is a cross-platform component library family with a two-bloodline architecture and eight repositories shipped together, ten docs sites in place — ten repositories inside and out.lh-ui is a cross-platform component library family with a two-bloodline architecture and eight repositories shipped together, ten docs sites in place — ten repositories inside and out.
vue
<script setup lang="ts">
import { LhEllipsis } from '@lh-ui/vue3'

const longText = 'lh-ui is a cross-platform component library family with a two-bloodline architecture and eight repositories'
</script>

<template>
  <LhEllipsis :content="longText" />
  <LhEllipsis :content="longText" :rows="2" />
</template>

Middle truncation ​

position="middle" only works on a single line; it goes through a JS cut that keeps the head and tail:

Middle truncation
lh-ui is…and out.

Expandable / collapsible ​

expandable renders an action; passing expanded makes it controlled (v-model). Clicking triggers change / clickAction / update:expanded:

Expand / collapse (unmanaged + action text from the language pack)
lh-ui is a cross-platform component library family with a two-bloodline architecture and eight repositories shipped together, ten docs sites in place — ten repositories inside and out.
vue
<LhEllipsis v-model:expanded="open" :content="longText" :rows="2" expandable @change="onChange" />

API ​

Ellipsis Props ​

PropDescriptionTypeDefault
contentText contentstring—
rowsNumber of lines shown when collapsed (≥1; invalid values are treated as 1)number1
expandableWhether expandable (renders an action)booleanfalse
expandedExpanded state (controlled; self-managed when not passed)boolean—
actionTextAction text (falls back to the ellipsis.expand/collapse language pack when not passed)string—
positionTruncation position (end / middle; middle is single-line only)'end' | 'middle''end'
ellipsisLabelAccessible name (falls back to a 40-character summary of the content when not passed)string—
sxsx quick-layout propsLhSxProps—

Ellipsis Events ​

EventDescriptionCallback
update:expandedExpanded state change (controlled write-back)expanded: boolean
changeExpanded state change (action click)expanded: boolean
clickActionAction clicked (fires together with change)—

Accessibility ​

The action is an independently focusable element (role="button" + tabindex="0", triggered by Enter / Space); aria-expanded stays in sync with the expanded state; the root node's aria-label comes from ellipsisLabel or the content summary.

Beauty of tradition, foundation of code