0.1.1 • Published 4 years ago

react-highlight-regex v0.1.1

Weekly downloads
2
License
MIT
Repository
-
Last release
4 years ago

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

Codesandbox Demo

$ 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

nametypedescription
textstringThe text to be highlighted.
matchRegExpRegular expression for content to be highlighted
highlightClassnamestring(optional)Classname for highlighted parts