finds.dev← search

// the find

bvaughn/react-highlight-words

★ 2,303 · JavaScript · MIT · updated Jan 2025

React component to highlight words within a larger body of text

A React component that wraps text and highlights matching search terms. It delegates the chunking logic to a separate `highlight-words-core` package, which makes it testable in isolation. Aimed at anyone building search UIs, autocomplete dropdowns, or any text that needs match highlighting.

The `findChunks` escape hatch is genuinely useful — you can swap in fuzzy matching, diacritic folding, or any custom logic without forking the component. The `sanitize` prop handles accent normalization cleanly, which most similar libraries ignore. The `activeIndex` prop for stepping through matches is a nice touch for keyboard-navigable search results. Core logic lives in `highlight-words-core` as a plain JS package, so you can reuse it outside React without pulling in the component.

The repo is effectively unmaintained — last meaningful activity was years ago, the CI uses CircleCI with a config that likely no longer runs, and it's still on Webpack 3-era build tooling. There are no TypeScript types shipped in the package; you need `@types/react-highlight-words` from DefinitelyTyped, which lags behind. The component only accepts a flat string for `textToHighlight`, so if your text already contains JSX or HTML, you're on your own. With 2300 stars and no active maintainer, any bug you hit is probably yours to fix.

View on GitHub → Homepage ↗

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →