Highlight Text
Usage
Pass the main string as children to Highlight component and string part that should be highlighted to highlight prop.
Properties
Pass the main string as children to Highlight component and string part that should be highlighted to highlight prop.
If the main string does not contain the highlighted part, it is left alone. The highlighted part is only the string of characters that have a matching sequence, whitespace is not included.
You can change styles of highlighted part if you do not like default styles.
Color
API References
Styles API
type T = "root" | "highlight";
Styles API | Type | Default | Annotation |
---|---|---|---|
className? | string | undefined | pass to root component <p> |
classNames? | Partial<Record<T, string>> | undefined | |
style? | CSSProperties | undefined | pass to root component <p> |
styles? | Partial<Record<T, CSSProperties>> | undefined | |
color | Property.Color | yellow | Key of CSS color, passed to mark component |
Props API
Props API | Type | Default | Annotation |
---|---|---|---|
text? | string | - | Define text to process the entire string |
children? | string | - | Define text to process the entire string |
highlight? | string | string[] | Substring or an array of substrings to highlight in children or text="" | |
el? | ElementType | <p> | element that will wrap the entire text |