# react-native-highlight-words

> A React Native port of react-highlight-words. This component is used to highlight words within a larger body of text.

Latest version **1.0.1** (published 2017-12-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-highlight-words
pnpm add react-native-highlight-words
yarn add react-native-highlight-words
bun add react-native-highlight-words
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2017-12-08 |
| First published | 2016-09-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/react-native-highlight-words) |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Clauderic Demers |
| Maintainers | bvaughn, clauderic |
| Keywords | react-native, react, reactjs, react-component, highlighter, highlight, text, words, matches, substring, occurrences, search |

## Links

- npm: https://www.npmjs.com/package/react-native-highlight-words
- Repository: https://github.com/clauderic/react-native-highlight-words
- Issues: https://github.com/clauderic/react-native-highlight-words/issues
- npm.io page: https://npm.io/package/react-native-highlight-words

## Dependencies (2)

- [prop-types](https://npm.io/package/prop-types.md) ^15.5.7
- [highlight-words-core](https://npm.io/package/highlight-words-core.md) ^1.0.3

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2017-12-08
- 1.0.0 — 2016-09-22

## README

# React Native Highlight Words
React Native component used to highlight words within a larger body of text. This is a port of [react-highlight-words](https://github.com/bvaughn/react-highlight-words).

Check out a [demo](https://getexponent.com/@clauderic/react-native-highlight-words) using Exponent.

## Installation
Using [npm](https://www.npmjs.com/package/react-native-highlight-words):
```
npm i --save react-native-highlight-words
```

## Usage

To use it, just provide it with an array of search terms and a body of text to highlight:

```jsx
import Highlighter from 'react-native-highlight-words';

<Highlighter
  highlightStyle={{backgroundColor: 'yellow'}}
  searchWords={['and', 'or', 'the']}
  textToHighlight='The dog is chasing the cat. Or perhaps they're just playing?'
/>
```

And the `Highlighter` component will highlight all occurrences of search terms within the text:

<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">


## Props

| Property        | Type          | Required? | Description                                                                                                             |
|:----------------|:--------------|:---------:|:------------------------------------------------------------------------------------------------------------------------|
| autoEscape      | Boolean       |           | Escape characters which are meaningful in regular expressions                                                           |
| highlightStyle  | Object        |           | Styles applied to highlighted text                                                                                      |
| sanitize        | Function      |           | Process each search word and text to highlight before comparing (eg remove accents); signature `(text: string): string` |
| searchWords     | Array<String> |     ✓     | Array of search words                                                                                                   |
| style           | Object        |           | Styles applied to the text wrapper                                                                                      |
| textToHighlight | String        |     ✓     | Text to highlight matches in                                                                                            |

## License
MIT License - fork, modify and use however you want.

<a target='_blank' rel='nofollow' href='https://app.codesponsor.io/link/oN9PDWZz8fQcbh9sxpDEUvD5/clauderic/react-native-highlight-words'>  <img alt='Sponsor' width='888' height='68' src='https://app.codesponsor.io/embed/oN9PDWZz8fQcbh9sxpDEUvD5/clauderic/react-native-highlight-words.svg' /></a>

---
_Source: https://npm.io/package/react-native-highlight-words · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
