README
React highlight regex
Highlight texts with regex!
This packages needs
String.prototype.matchAll
to work properly. Check out availability on caniuse before use.
Example and Usage
$ yarn add react-highlight-regex
import * as React from 'react';
import { Highlight } from 'react-highlight-regex';
function BasicUsage() {
return (
<Highlight match={/a|t/} text="An apple a day keeps the doctor away." />
);
}
Props
name | type | description |
---|---|---|
text | string | The text to be highlighted. |
match | RegExp | Regular expression for content to be highlighted |
highlightClassname | string(optional) | Classname for highlighted parts |