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
<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:
Expandable / collapsible
expandable renders an action; passing expanded makes it controlled (v-model). Clicking triggers change / clickAction / update:expanded:
<LhEllipsis v-model:expanded="open" :content="longText" :rows="2" expandable @change="onChange" />API
Ellipsis Props
| Prop | Description | Type | Default |
|---|---|---|---|
| content | Text content | string | — |
| rows | Number of lines shown when collapsed (≥1; invalid values are treated as 1) | number | 1 |
| expandable | Whether expandable (renders an action) | boolean | false |
| expanded | Expanded state (controlled; self-managed when not passed) | boolean | — |
| actionText | Action text (falls back to the ellipsis.expand/collapse language pack when not passed) | string | — |
| position | Truncation position (end / middle; middle is single-line only) | 'end' | 'middle' | 'end' |
| ellipsisLabel | Accessible name (falls back to a 40-character summary of the content when not passed) | string | — |
| sx | sx quick-layout props | LhSxProps | — |
Ellipsis Events
| Event | Description | Callback |
|---|---|---|
| update:expanded | Expanded state change (controlled write-back) | expanded: boolean |
| change | Expanded state change (action click) | expanded: boolean |
| clickAction | Action 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.

