Skip to content

Highlight

Free

Marks the words in a text that match a search, so people see why a result came up. It can match whole words, letter case, and words with accents.

  • Base UI
  • React 19
  • Tailwind CSS 4

Added Nov 9, 2026 · MIT + Commons Clause

Playground

Loading the preview

Props

Pass the search term as highlight, and the text as children. A blank search shows the text as it is.

search-snippet.tsx

Highlight

<span>
PropTypeDefaultDescription
caseSensitiveboolean—Match the exact case. Off by default: "key" also finds "Key".
ignoreAccentsboolean—Match letters with and without accents: "cafe" also finds "Café". It removes only the combining diacritical marks (U+0300 to U+036F: the accents of Latin, Greek, and Cyrillic), not the vowel signs of Devanagari or Thai, which change the word. Off by default.
wholeWordboolean—Match only whole words: "key" finds "key" but not "Keychain". Off by default.
localestring—The language of the text, for lowercasing (Turkish "I" → "ı") and word edges. Without it, the matcher uses the locale-free toLowerCase, so the server and the browser give the same marks. A tag that is not valid BCP 47 ("en_US") falls back to no locale, with a warning in development, so a locale from user data cannot crash the render.
childrenReactNode—The content to search: a plain string, or rich content (nested elements). In rich content each text piece is searched on its own (see the rich-content notes on Highlight).
highlightstring | readonly string[]NO_TERMSOne search term or many. Blank terms are skipped, so an empty search field marks nothing.
rangesreadonly HighlightRange[]—Ranges to mark, [start, end) in UTF-16 units, in place of highlight (a fuzzy search or a server gives them). They are clamped, sorted, merged, and widened to whole characters. Plain string children only: in rich content the indexes have no single text to point into.
tone"destructive""info""neutral""success""warning"—The tone of every mark.
markPropsOmit<MarkProps, "children" | "tone">—Props for every mark: className, cue, data attributes.
render—The root element, in place of the <span>: render={<div />} for rich content with blocks (paragraphs, lists), which a <span> may not hold. It gets the props and the marked content.
...props<span> attributes—Every other attribute goes to the <span>, with a ref.
  • Use it to show why a search result matches.
  • Use highlight for one term or many.
  • Use ranges when a fuzzy search or a server gives the places to mark.
  • Use wholeWord, caseSensitive, ignoreAccents, and locale to change the matching.
  • For a phrase that you choose by hand, use a Mark.

Each match is a native <mark>, so the text stays in place and in reading order.

It has no hooks and takes no focus. It renders on the server.

Built with

Installs with Highlight

Components
Mark
  1. AddedHighlight, with Mark.
Open the release