Chatroom Highlighter
Overview
The Highlighter
component is designed to highlight specific text within a larger body of text. It takes in a string of text and a list of keywords, dynamically rendering the keywords in a highlighted format while keeping the surrounding text in a normal style. This is particularly useful for enhancing readability and drawing attention to important terms or phrases in chat or document contexts.
Customisation
The highlighter can be customised using the searchedHighlightedTextStyle
and searchedNonHighlightedTextStyle
Props
Property | Type | Description | Required |
---|---|---|---|
autoEscape | boolean | Specifies whether to auto escape the text. | |
highlightStyle | TextStyle[] or null | Defines the style to apply to highlighted text. | |
searchWords | string[] | An array of words to search and highlight in the text. | ✔️ |
textToHighlight | string | The text that will be highlighted. | ✔️ |
sanitize | Function | A function to sanitize the text before highlighting. | |
style | TextStyle[] or null | Specifies the style of the text. |