Mark

Marks the terms you pick inside a text, for search results and key words. It matches without regard to case and keeps the text as it was written.

General

Pass the text as a string and the term in highlight.

Several terms

Pass a list to mark more than one term. When terms overlap, the longest one wins.

Use the value of an input as the term to mark the matches while you type.

APIs

Mark.Props

AttributeDescriptionTypeAccepted valuesDefault
childrentext to search instring-''
highlightterms to mark, matched without regard to casestring / string[]-''
...native props, passed to the root elementHTMLAttributes'id', 'className', ...-

Ref

The ref points at the root span.

Accessibility

Each match renders as a native mark element, which browsers and most screen readers treat as highlighted text. The meaning does not rely on the color alone.

Edit this page on GitHub