# @walltowall/highlighter

> React component for rendering highlighted words from a string.

Latest version **0.1.2** (published 2020-02-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install @walltowall/highlighter
pnpm add @walltowall/highlighter
yarn add @walltowall/highlighter
bun add @walltowall/highlighter
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2020-02-17 |
| First published | 2020-02-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 13.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Wall-to-Wall Studios |
| Maintainers | kangken, asyarb, angeloashmore, walltowall-dev |
| Keywords | react, highlight, render, props |

## Links

- npm: https://www.npmjs.com/package/@walltowall/highlighter
- npm.io page: https://npm.io/package/@walltowall/highlighter

## 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.1.2 (latest) — 2020-02-17

## README

# Highlighter

React component for rendering highlighted words from a string.

## Installation

```sh
# npm
npm install @walltowall/highlighter

# yarn
yarn add @walltowall/highlighter
```

## Usage

Supply your `searchTerm` and the React component you wish to render with
`renderHighlight` for any matched word. The render function will receive the
`word` as its first argument and the current index match as its second argument.

```jsx
import { Highlighter } from '@walltowall/highlighter'

const Example = () => {
  return (
    <Highlighter
      searchTerm="word"
      renderHighlight={(word, idx) => <em key={idx}>{word}</em>}
    >
      Highlight your desired word! Any word will be wrapped with your
      `renderHighlight`!
    </Highlighter>
  )
}
```

`<Highlighter>` children **must** be a plain string. Providing a component such
as a `<div>` will result in an error.

## API

| Prop            | Required? | Description                                    |
| --------------- | :-------: | ---------------------------------------------- |
| searchTerm      |    Yes    | The word to search for in the provided string. |
| renderHighlight |    Yes    | A render prop to render any word match.        |

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