# react-highlighter

> Highlight select fragments of texts

Latest version **0.4.3** (published 2018-08-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-highlighter
pnpm add react-highlighter
yarn add react-highlighter
bun add react-highlighter
```

## Health

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

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

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.3 |
| Published | 2018-08-28 |
| First published | 2015-03-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/react-highlighter) |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 109 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 161 |
| Author | Helior Colorado |
| Maintainers | helior |
| Keywords | react-component, react, highlight |

## Links

- npm: https://www.npmjs.com/package/react-highlighter
- Repository: https://github.com/helior/react-highlighter
- Issues: https://github.com/helior/react-highlighter/issues
- npm.io page: https://npm.io/package/react-highlighter

## Dependencies (4)

- [blacklist](https://npm.io/package/blacklist.md) ^1.1.4
- [prop-types](https://npm.io/package/prop-types.md) ^15.6.0
- [create-react-class](https://npm.io/package/create-react-class.md) ^15.6.2
- [escape-string-regexp](https://npm.io/package/escape-string-regexp.md) ^1.0.5

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

- 0.4.3 (latest) — 2018-08-28
- 0.4.2 — 2017-11-02
- 0.4.1 — 2017-10-04
- 0.4.0 — 2017-06-09
- 0.3.5 — 2017-06-09
- 0.3.4 — 2017-05-27
- 0.3.3 — 2016-07-16
- 0.3.2 — 2016-05-11
- 0.3.1 — 2016-02-29
- 0.3.0 — 2016-01-07
- 0.2.4 — 2016-01-07
- 0.2.3 — 2016-01-05
- 0.2.2 — 2015-05-09
- 0.2.1 — 2015-03-28
- 0.2.0 — 2015-03-28
- … 5 more at https://npm.io/package/react-highlighter/versions

## README

[![npm version](https://badge.fury.io/js/react-highlighter.svg)](http://badge.fury.io/js/react-highlighter)
[![Build Status](https://travis-ci.org/helior/react-highlighter.svg?branch=master)](https://travis-ci.org/helior/react-highlighter)
[![Coverage Status](https://coveralls.io/repos/github/helior/react-highlighter/badge.svg?branch=master)](https://coveralls.io/github/helior/react-highlighter?branch=master)

# react-highlighter
Highlight select fragments of a string using an HTML element and/or a class.

## Installation

```
npm install react-highlighter --save
```

## Usage
```js
var Highlight = require('react-highlighter');

<Highlight search="brown">The quick brown fox jumps over the lazy dog</Highlight>
```
## Props
- `search`: The string of text (or Regular Expression) to highlight
- `caseSensitive`: Determine whether string matching should be case-sensitive. Not applicable to regular expression searches. Defaults to `false`
- `ignoreDiacritics`: Determine whether string matching should ignore diacritics. Defaults to `false`
- `diacriticsBlacklist`: These chars are treated like characters that don't have any diacritics.  Not applicable ignoreDiacritics is `false`. Defaults to none
- `matchElement`: HTML tag name to wrap around highlighted text. Defaults to `mark`
- `matchClass`: HTML class to wrap around highlighted text. Defaults to `highlight`
- `matchStyle`: Custom style for the match element around highlighted text.


## Development
### Testing
Using Mocha/Chai/React.addons.TestUtils for testing.
```
npm test
```

### Code Coverage
Generate a report using Istanbul to make sure your tests are touching everything! FYI, Travis will fail the build if there isn't at least 90% of statement coverage and 100% function coverage.
```
npm run coverage
```

Coveralls.io integration requires that the environment variable `COVERALLS_REPO_TOKEN` is set.

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