Highlight
Keyword highlighting: the content is split into plain text and hit segments by keywords (splitByKeywords: case normalization, longest match, non-overlapping scan); hit segments render as lh-highlight__mark. Serves search-result summaries, log keyword annotation and similar scenarios.
Platform differences (registered): no platform specialization on this port — splitting, hit math and the accessibility label all reuse share-core pure functions; the view renders Segment[] as a text loop (uni-app inline text nodes), and the mark visuals come from the share style source.
Basic usage
<template>
<lh-highlight content="lh-ui 是一个跨端组件库家族" keywords="跨端" />
<lh-highlight content="LH-UI 跨端组件库,lh-ui 家族" keywords="lh-ui" />
</template>Multiple keywords and case sensitivity
keywords accepts an array of strings; when several keywords match at the same position the longest wins. caseSensitive defaults to false (case-normalized matching, the hit text is emitted as-is):
<lh-highlight
content="lh-ui 跨端组件库家族,双血脉架构,八仓齐发"
:keywords="['lh-ui', '跨端组件库', '组件库']"
/>
<lh-highlight content="LH-UI 跨端组件库,lh-ui 家族" keywords="lh-ui" case-sensitive />Content truncation and custom highlight styles
When maxLength > 0 the content is truncated and suffixed with … before splitting (stable ellipsis position); highlightClass / highlightStyle are forwarded to the hit mark:
<lh-highlight
content="lh-ui 是一个跨端组件库家族,双血脉架构,八仓齐发"
keywords="双血脉"
:max-length="20"
/>
<lh-highlight
content="自定义类名与内联样式"
keywords="自定义"
highlight-class="my-highlight"
highlight-style="color: #B87800; text-decoration: underline;"
/>Props
| Prop | Description | Type | Default |
|---|---|---|---|
| content | Text content (required) | string | — |
| keywords | Keywords (string or array; empty strings are ignored) | string | string[] | — |
| caseSensitive | Case sensitive (false matches case-normalized) | boolean | false |
| highlightClass | Extra class appended to the hit mark | string | — |
| highlightStyle | Inline style string for the hit mark | string | — |
| maxLength | Max content length (>0 truncates and appends … before splitting) | number | — |
| highlightLabel | Accessibility label (falls back to a 40-char content summary) | string | — |
| customClass | Custom class (forwarded to the root node) | string | — |
| sx | sx quick layout props | LhSxProps | — |
Accessibility
The root aria-label defaults to a 40-char content summary and can be customized with highlightLabel; when nothing matches, the root gets the lh-highlight--plain modifier so consumers can tell the "no hit" state apart.

