react-highlight-words

A React component that highlights matching search terms within a body of text

Library
npm
v0.21.0
2,303stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
43/100Fair
Development Activity0
Maintenance20
Community52
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
73/100Good
Architecture70
Code Quality72
Innovation60
Learning Curve90

react-highlight-words renders a body of text with an array of search words wrapped in a highlight element, defaulting to the semantic <mark> tag but swappable for any custom React component. It’s built as a thin, focused wrapper around highlight-words-core, the same author’s underlying matching logic, so string search terms are automatically converted to case-insensitive regexes (with optional auto-escaping) without requiring the consumer to hand-write matching code.

The component exposes granular styling and behavior props — separate class names and inline styles for highlighted vs. unhighlighted text, an activeIndex/activeClassName pair for marking one match as currently selected, and a sanitize hook for normalizing text (e.g. stripping accents) before comparison — making it a common building block for search-result snippets, autocomplete dropdowns, and in-page find UIs.

What You Get

  • A <Highlighter searchWords={[...]} textToHighlight={...} /> component that wraps all matches in a <mark> (or custom tag)
  • Automatic conversion of string search terms into regexes, with autoEscape to safely handle special characters
  • Separate styling hooks for highlighted vs. unhighlighted text (highlightClassName/highlightStyle, unhighlightClassName/unhighlightStyle)
  • An activeIndex/activeClassName/activeStyle trio for marking one specific match as the currently selected result
  • A sanitize prop for normalizing text before comparison (e.g. accent stripping) without altering the displayed text
  • Support for custom highlightTag/unhighlightTag React components instead of the default mark/span elements

Common Use Cases

  • Highlighting the matched query term(s) inside search result snippets in a React app
  • Building autocomplete or typeahead dropdowns that show which part of each suggestion matched the user’s input
  • Implementing an in-page “find in text” feature with a currently-active match indicator
  • Highlighting multiple distinct terms (e.g. tags or keywords) within displayed content simultaneously
  • Normalizing accented or differently-cased text before matching, via the sanitize prop, while preserving original display text

Under The Hood

Architecture: The published component is a thin ~120-line wrapper (src/Highlighter.js) around chunk-finding logic delegated to the sibling highlight-words-core package (also maintained by the author), which computes match/no-match text chunks; Highlighter.js then maps those chunks to React elements, applying the configured highlight/unhighlight tags, classes, and styles, with activeIndex handled as a simple chunk-index comparison during the render pass. Tech Stack: Plain JavaScript (no TypeScript) built with Webpack across several purpose-specific configs (dist.cjs, dist.umd, website, dev) to produce both a CommonJS distribution and a UMD bundle, tested via Karma rather than Jest, and linted with standard (zero-config ESLint preset) run as a prebuild step. Code Quality: The core logic is covered by a single, fairly thorough Highlighter.test.js exercising the main prop combinations, plus a documented CodeSandbox example for custom findChunks usage; the project has had minimal commit activity since its early releases, so its small, stable surface area has changed little in practice. API Design: The prop table is exhaustive and self-documenting in the README — every visual and behavioral variation (active match, custom tags, sanitize hook) is exposed as a discrete, independently optional prop, which keeps the common case (searchWords + textToHighlight) to two lines while still supporting advanced customization.

Used by 9 apps in this directory

TypeScript
72%
AGPL 3.0

APITable

Low Code Platforms · Databases

15,526

API-first collaborative spreadsheet-database platform that auto-generates REST APIs and lets teams build internal tools, CRMs, and dashboards without code.

View details
53
Repo Health
77
Technical
60
Dependency
Built with
TypeScript72%
Java22%
Updated 9 months ago
JavaScript
95%
MIT

AnythingLLM

Developer Tools · Automation · AI Assistants

64,914

The all-in-one AI platform for private document chat, no-code agents, and local LLMs with zero setup friction.

View details
91
Repo Health
78
Technical
68
Dependency
Built with
JavaScript95%
Updated today
TypeScript
88%
MIT

DevTools-X

Developer Tools

1,532

41 offline-first developer utilities in a single 10MB cross-platform desktop app — no Electron, no cloud, no compromise.

View details
51
Repo Health
68
Technical
68
Dependency
Built with
TypeScript88%
Updated 2 months ago
TypeScript
100%
Other

Dub

Marketing · Analytics

24,521

The open-source link attribution platform for short links, conversion tracking, and affiliate programs — powering 100M+ clicks monthly.

View details
81
Repo Health
78
Technical
65
Dependency
Built with
TypeScript100%
Updated today
TypeScript
48%
AGPL 3.0

Grafana

Monitoring · Analytics

76,300

The open-source observability platform that unifies metrics, logs, and traces from any data source into dynamic, queryable dashboards.

View details
95
Repo Health
91
Technical
65
Dependency
Built with
TypeScript48%
Go46%
Updated today
TypeScript
71%
Other

highlight.io

Developer Tools · Analytics · Monitoring

9,367

Open-source full-stack monitoring that unifies session replay, error tracking, logging, and distributed tracing so you can stop context-switching between tools.

View details
69
Repo Health
78
Technical
66
Dependency
Built with
TypeScript71%
Go16%
Updated yesterday
TypeScript
98%
MIT

GraphQL Hive

Developer Tools · Devops · Monitoring

485

Open-source GraphQL schema registry and observability platform with breaking change detection, federation support, and CI/CD integration for teams of any size.

View details
90
Repo Health
81
Technical
70
Dependency
Built with
TypeScript98%
Updated today
Rust
67%
Apache 2.0

Rivet

AI Agents · Developer Tools

6,065

Stateful actors as a primitive for AI agents, real-time collaboration, and durable execution — with in-memory state, WebSockets, queues, and scheduling built in.

View details
86
Repo Health
81
Technical
66
Dependency
Built with
Rust67%
TypeScript29%
Updated today
JavaScript
59%
AGPL 3.0

ToolJet

Low Code Platforms · No Code Platforms · AI Agents

40,458

Open-source AI-native platform to build and deploy internal tools, workflows, and AI agents with a visual drag-and-drop builder and 80+ data source integrations.

View details
94
Repo Health
81
Technical
65
Dependency
Built with
JavaScript59%
TypeScript33%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search