{"_id":"react-highlight-words@1.0.0","bugs":{"url":"https://github.com/bvaughn/react-highlight-words/issues"},"dist":{"shasum":"0459768f1476afc7e1f3a53ea32af98b8305af0b","tarball":"http://registry-npm.ywwl.com/react-highlight-words/download/react-highlight-words-1.0.0.tgz","fileCount":9,"integrity":"sha512-783Dim5Q6X51x4yGlU2+XDr5L3r9P+3iI1zuRx4khbjqNOZObUoGOtZ5V7UdN8zrpz/IUo+cAdSoYJu4Y0Vo1w==","signatures":[{"sig":"MEYCIQD+yIwFov+pgJpn7Zq/DuSuDhbjE7nRrof1TY4nu/SZlwIhAOWqaX4Yu8ZFjCVffm5CXTFKt3YCkIF3I7nfhyJ4u5l/","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIE+ywUhslI7nESHPhj33maixa5PFrGK8skf0O8fGFfveAiAMFojIp5COnaOgcssvdfajpYUhaux9JP9ua19c9ZMd1g=="}],"unpackedSize":47676,"size":11833,"noattachment":false,"key":"/react-highlight-words/-/react-highlight-words-1.0.0.tgz"},"main":"dist/react-highlight-words.cjs","name":"react-highlight-words","type":"module","types":"dist/react-highlight-words.d.cts","author":{"url":"https://github.com/bvaughn/","name":"Brian Vaughn","email":"brian.david.vaughn@gmail.com"},"module":"dist/react-highlight-words.js","exports":{".":{"import":{"types":"./dist/react-highlight-words.d.ts","default":"./dist/react-highlight-words.js"},"require":{"types":"./dist/react-highlight-words.d.cts","default":"./dist/react-highlight-words.cjs"}},"./package.json":"./package.json"},"gitHead":"48a968da1750bcab4ba6ab62e6a077a52de88407","license":"MIT","scripts":{"dev":"vite","tsc":"tsc -b","lint":"eslint .","test":"vitest","build":"pnpm run /^build:.*/","compile":"pnpm run --sequential /^compile:.*/","preview":"vite preview","test:ci":"vitest run","prettier":"prettier --write \"**/*.{css,html,js,json,jsx,ts,tsx}\"","build:lib":"cross-env TARGET=lib vite build","build:docs":"cross-env TARGET=docs vite build","prerelease":"rm -rf dist && pnpm run build:lib","test:debug":"vitest --inspect-brk=127.0.0.1:3000 --no-file-parallelism","prettier:ci":"prettier --check \"**/*.{css,html,js,json,jsx,ts,tsx}\"","compile:docs":"tsx ./scripts/compile-docs","compile:examples":"tsx ./scripts/compile-examples","compress:og-image":"tsx ./scripts/compress-og-image","compile:search-index":"tsx ./scripts/compile-search-index"},"version":"1.0.0","_npmUser":{"name":"brianvaughn","email":"briandavidvaughn@gmail.com"},"homepage":"https://react-highlight-words.vercel.app/","keywords":["react","reactjs","react-component","highlighter","highlight","text","words","matches","substring","occurrences","search"],"repository":{"url":"git+https://github.com/bvaughn/react-highlight-words.git","type":"git"},"_npmVersion":"11.4.2","description":"React component to highlight words within a larger body of text","directories":{},"lint-staged":{"**/*":"prettier --write --ignore-unknown"},"maintainers":[{"name":"brianvaughn","email":"briandavidvaughn@gmail.com"},{"name":"clauderic","email":"clauderic.d@gmail.com"},{"name":"sergei-startsev","email":"ai@programist.ru"}],"sideEffects":false,"_nodeVersion":"24.3.0","contributors":[{"url":"https://github.com/bvaughn/","name":"Brian Vaughn","email":"brian.david.vaughn@gmail.com"}],"dependencies":{"highlight-words-core":"2.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.21.0","vite":"^7.0.4","bytes":"^3.1.2","husky":"^9.1.7","jsdom":"^26.1.0","react":"^19.2.3","sharp":"^0.34.5","eslint":"^9.30.1","marked":"^16.4.1","terser":"^5.43.1","vitest":"^3.2.4","csstype":"^3.1.3","globals":"^16.3.0","postcss":"^8.5.6","latinize":"^2.0.0","prettier":"3.6.2","cross-env":"^10.1.0","react-dom":"^19.2.3","@eslint/js":"^9.30.1","typescript":"~5.8.3","@types/node":"^24.2.0","lint-staged":"^16.1.4","markdown-it":"^14.1.0","tailwindcss":"^4.1.11","@types/bytes":"^3.1.5","@types/react":"^19.2.3","@types/sharp":"^0.32.0","@types/latinize":"^0.2.18","react-lib-tools":"0.0.60","vite-plugin-dts":"^4.5.4","@types/react-dom":"^19.2.3","vite-plugin-svgr":"^4.3.0","@tailwindcss/vite":"^4.1.11","typescript-eslint":"^8.35.1","@types/markdown-it":"^14.1.2","@testing-library/react":"^16.3.0","react-docgen-typescript":"^2.4.0","@vitejs/plugin-react-swc":"^3.10.2","rollup-plugin-visualizer":"^6.0.3","@testing-library/jest-dom":"^6.6.4","eslint-plugin-react-hooks":"^5.2.0","rollup-preserve-directives":"^1.1.3","eslint-plugin-react-refresh":"^0.4.20","prettier-plugin-tailwindcss":"^0.7.1","@csstools/postcss-oklab-function":"^4.0.11"},"peerDependencies":{"react":"^16.3.0 || ^17.0.0-0 || ^18.0.0-0 || ^19.0.0-0"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/react-highlight-words_1.0.0_1791744325457_0.7694592487713074"},"readme":"<img src=\"https://react-highlight-words.vercel.app/og.png\" alt=\"react-highlight-words logo\" width=\"400\" height=\"210\" />\n\nReact component to highlight words within a larger body of text.\n\n## Installation\n\nBegin by installing the library from NPM:\n\n```sh\nnpm install react-highlight-words\n```\n\n## TypeScript types\n\nTypeScript definitions are included within the published `dist` folder.\n\n## Documentation\n\nDocumentation and examples for this project are available at [react-highlight-words.vercel.app](https://react-highlight-words.vercel.app/).\n\n## Usage\n\nTo use it, just provide it with an array of search terms and a body of text to highlight.\n\n```tsx\nimport Highlighter from \"react-highlight-words\";\n\nfunction Example() {\n  return (\n    <Highlighter\n      highlightClassName=\"YourHighlightClass\"\n      searchWords={[\"and\", \"or\", \"the\"]}\n      textToHighlight=\"The dog is chasing the cat. Or perhaps they're just playing?\"\n    />\n  );\n}\n```\n\nAnd the `Highlighter` will mark all occurrences of search terms within the text:\n\n<img width=\"368\" alt=\"screen shot 2015-12-19 at 8 23 43 am\" src=\"https://cloud.githubusercontent.com/assets/29597/11914033/e3c319f6-a629-11e5-896d-1a5ce22c9ea2.png\">\n\n### Highlighter\n\n<!-- Highlighter:description:begin -->\nHighlights all occurrences of one or more search terms within a larger body of text.\n\nHighlighted matches are wrapped in a `<mark>` element by default, and unhighlighted text is wrapped in a `<span>`.\nBoth of these can be customized with the `highlightTag` and `unhighlightTag` props.\n\nℹ️ Any other props (such as `title` or `data-*` attributes) are applied to the outer/wrapper `<span>`, and a `ref` is forwarded to it.\n<!-- Highlighter:description:end -->\n\n#### Required props\n\n<!-- Highlighter:required-props:begin -->\n\n<table>\n  <thead>\n    <tr>\n      <th>Name</th>\n      <th>Description</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td>searchWords</td>\n      <td><p>Array of search words.\nString search terms are matched literally, unless <code>autoEscape</code> is false\n(in which case they are treated as regular expressions, and strings that aren&#39;t valid regular expressions are matched literally).\nRegExp search terms are used as-is (with their own flags).</p>\n</td>\n    </tr>\n    <tr>\n      <td>textToHighlight</td>\n      <td><p>Text to highlight matches in.</p>\n<p>ℹ️ Browsers collapse whitespace and newlines by default; to preserve them, set the <code>white-space</code> style (e.g. <code>style={{ whiteSpace: &quot;pre-wrap&quot; }}</code>).</p>\n</td>\n    </tr>\n  </tbody>\n</table>\n\n<!-- Highlighter:required-props:end -->\n\n#### Optional props\n\n<!-- Highlighter:optional-props:begin -->\n\n<table>\n  <thead>\n    <tr>\n      <th>Name</th>\n      <th>Description</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td>className</td>\n      <td><p>Class name applied to the outer/wrapper <code>&lt;span&gt;</code>.</p>\n</td>\n    </tr>\n    <tr>\n      <td>activeClassName</td>\n      <td><p>Class name applied to the active match.</p>\n<p>ℹ️ Use along with <code>activeIndex</code>.</p>\n</td>\n    </tr>\n    <tr>\n      <td>activeIndex</td>\n      <td><p>Index of the match that should be actively highlighted.</p>\n<p>ℹ️ Use along with <code>activeClassName</code> or <code>activeStyle</code>.</p>\n</td>\n    </tr>\n    <tr>\n      <td>activeStyle</td>\n      <td><p>Inline styles applied to the active match.</p>\n<p>ℹ️ Use along with <code>activeIndex</code>.</p>\n</td>\n    </tr>\n    <tr>\n      <td>autoEscape</td>\n      <td><p>Match string search terms literally (defaults to <code>true</code>).\nSet to <code>false</code> to treat them as regular expressions.\n(They are compiled without the <code>u</code> flag, so syntax that requires it, such as <code>\\p{L}</code>, only works in RegExp search terms.)</p>\n<p>⚠️ Only set this to <code>false</code> for trusted search terms;\na malicious regular expression can take an extremely long time to run.</p>\n</td>\n    </tr>\n    <tr>\n      <td>caseSensitive</td>\n      <td><p>Match string search terms case sensitively.\nRegExp search terms are case sensitive unless they have the <code>i</code> flag.</p>\n</td>\n    </tr>\n    <tr>\n      <td>findChunks</td>\n      <td><p>Custom function to search for matching chunks.\nThis makes it possible to use arbitrary logic when looking for matches.</p>\n<p>It receives the search options (with defaults applied) and returns the <code>start</code> and <code>end</code> index of each range of text to highlight,\nalong with the <code>searchIndex</code> of the search word that matched it.\nOverlapping ranges are combined automatically.</p>\n<p>See the default <code>findChunks</code> function in <a href=\"https://github.com/bvaughn/highlight-words-core\">highlight-words-core</a> for reference.</p>\n</td>\n    </tr>\n    <tr>\n      <td>highlightClassName</td>\n      <td><p>Class name applied to highlighted text,\nor an object mapping search term matches to class names.</p>\n<p>ℹ️ Object keys are compared with the matched text first, then with the string search term that matched it\n(case insensitively, unless <code>caseSensitive</code> is true).</p>\n</td>\n    </tr>\n    <tr>\n      <td>highlightStyle</td>\n      <td><p>Inline styles applied to highlighted text.</p>\n</td>\n    </tr>\n    <tr>\n      <td>highlightTag</td>\n      <td><p>Type of tag to wrap around highlighted matches.\nDefaults to <code>mark</code> but can also be a React component (class or function).</p>\n<p>ℹ️ Custom components will receive <code>children</code>, <code>className</code>, <code>highlightIndex</code>, <code>searchIndex</code>, and <code>style</code> props.</p>\n</td>\n    </tr>\n    <tr>\n      <td>sanitize</td>\n      <td><p>Process each string search word and the text to highlight before comparing (e.g. to remove accents).\nMatches always refer to the original text, even if sanitizing changes its length (e.g. &quot;Æ&quot; to &quot;AE&quot;).</p>\n<p>ℹ️ Sanitizing should transform characters independently;\nif it changes the text, it is applied to each character separately.\nRegExp search terms are not sanitized, but they are matched against the sanitized text.</p>\n</td>\n    </tr>\n    <tr>\n      <td>unhighlightClassName</td>\n      <td><p>Class name applied to unhighlighted text.</p>\n</td>\n    </tr>\n    <tr>\n      <td>unhighlightStyle</td>\n      <td><p>Inline styles applied to unhighlighted text.</p>\n</td>\n    </tr>\n    <tr>\n      <td>unhighlightTag</td>\n      <td><p>Type of tag applied to unhighlighted parts of the text.\nDefaults to <code>span</code> but can also be a React component (class or function).</p>\n</td>\n    </tr>\n  </tbody>\n</table>\n\n<!-- Highlighter:optional-props:end -->\n\n### Custom highlight tag\n\nBy default, this component uses an HTML Mark Text element (`<mark>`) to wrap matched text, but you can inject a custom\ntag using the `highlightTag` property. This tag should be a React component that accepts the following properties:\n\n| Property         | Type   | Description            |\n| ---------------- | ------ | ---------------------- |\n| `children`       | String | Text to be highlighted |\n| `className`      | String | Class name(s) to apply |\n| `highlightIndex` | Number | Index of matched text  |\n| `searchIndex`    | Number | Index of the matching search word |\n| `style`          | Object | Inline styles to apply |\n\nFor example:\n\n```tsx\nimport { type HighlightTagProps } from \"react-highlight-words\";\n\nfunction Highlight({ children, highlightIndex }: HighlightTagProps) {\n  return <strong className=\"highlighted-text\">{children}</strong>;\n}\n```\n\n## License\n\nMIT License - fork, modify and use however you want.\n","publish_time":1791744325536,"_cnpm_publish_time":1791744325536,"dist-tags":{"latest":"1.0.0"}}