Show · Highlight
Highlight
highlight specific content

code demo

How to import

Semi support Highlight component since v2.24.0

Basic usage

You can specify keywords to be highlighted with searchWords and source text with sourceString

Specify highlight style

By default, the highlighted text will have its own text style, the text color is black, and the background color is --semi-yellow-4.
In dark mode, the text color is white, and the background color is --semi-yellow-2.
When you need to customize different highlight styles, you can specify them through highlightClassName, highlightStyle

Specify the highlight tag

Semi will wrap the text matching searchWords in sourceString with mark tag by default, you can also re-specify the tag through component

API Reference

Highlight

propertydescriptiontypedefault value
searchWordsexpected highlighted textstring[]''
sourceStringsource textstring
componentHighlight labelstringmark
highlightClassNameThe style class name of the highlight tagReactNode-
highlightStyleInline style for highlight tagsReactNode-
caseSensitiveIs case sensitivefalse-
autoEscapeWhether to automatically escapetrue-