Skip to content

Ellipsis ​

Text truncation: multi-line CSS line-clamp first (rows driven by the --lh-ellipsis-rows CSS variable); position="middle" uses JS truncation (truncateMiddle, uniform across ports). Serves expand/collapse, middle truncation and custom action scenarios.

Platform differences (registered): no platform specialization on this port — end uses -webkit-line-clamp (supported by every port's CSS engine), middle uses the share-core truncateMiddle JS truncation; all truncation and state math reuses share-core pure functions.

Basic usage ​

vue
<template>
  <lh-ellipsis :content="longText" />
  <lh-ellipsis :content="longText" :rows="2" />
  <lh-ellipsis :content="longText" position="middle" />
</template>

<script setup lang="ts">
  const longText = 'lh-ui 是一个跨端组件库家族,双血脉架构,八仓齐发,文档站十站齐备'
</script>

Controlled expansion ​

Passing expanded makes the state controlled (v-model:expanded); change fires on every action click:

vue
<lh-ellipsis :content="longText" :rows="2" expandable v-model:expanded="open" />

Props ​

PropDescriptionTypeDefault
contentText contentstring—
rowsVisible rows when collapsed (>= 1; invalid values fall back to 1)number1
expandableRender the expand / collapse actionbooleanfalse
expandedExpanded state (controlled; internal when absent)boolean—
actionTextAction label (falls back to i18n ellipsis.expand / collapse)string—
positionTruncation position: end uses CSS line-clamp; middle uses single-line JS truncation'end' | 'middle''end'
ellipsisLabelAccessibility label (falls back to a 40-char content summary)string—
customClassCustom class (forwarded to the root node)string—
sxsx quick layout propsLhSxProps—

Events ​

EventDescriptionCallback
update:expandedExpanded state write-back (v-model:expanded)expanded: boolean
changeExpanded state changeexpanded: boolean
clickActionAction clicked (fires together with change)—

Accessibility ​

  • The action is a standalone focusable node (role="button"); aria-expanded syncs with the expanded state; the root aria-label defaults to a 40-char content summary.