Skip to content

Highlight

Highlights case-insensitive literal query matches with semantic mark elements while preserving the original text.

Search results explain why each result matched.
<Highlight
query="result"
>
Search results explain why each result matched.
</Highlight>
Highlight several matching terms in the same sentence.
<Highlight
query={['highlight', 'matching', 'sentence']}
>
Highlight several matching terms in the same sentence.
</Highlight>

Highlights case-insensitive literal query matches with semantic mark elements while preserving the original text.

PropTypeDefaultDescription
children*stringText in which query matches are highlighted.
classNamestringAdditional CSS class names applied to the root span.
data-testidstringTest ID applied to the root span.
query*string | string[]Literal substring or substrings to highlight. Matching is case-insensitive; empty and whitespace-only queries are ignored.
refRef<HTMLSpanElement>Ref forwarded to the root span.
styleCSSPropertiesInline styles applied to the root span.