highlight-react-text
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

highlight-react-text

This small library is created to highlight text in react.

Why create this library?

I just wanted to try and created a small library that I can use to highlight text while searching.

Usage

  1. Highlight Component
import { Highlighter } from "highlight-react-text";

const Text = () => {
  return (
    <Highlighter searchText="highlight">
      This is the highlighted text we are looking at.
    </Highlighter>
  );
};
  1. useHighlighter custom react hook
import { Highlighter } from "highlight-react-text";

const Text = () => {
  const { highlights } = useHighlighter({
    searchText: "highlight",
    text: "This is the highlighted text we are looking at",
  });

  return <p>{highlights}</p>;
};

Package Sidebar

Install

npm i highlight-react-text

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

34 kB

Total Files

21

Last publish

Collaborators

  • itsmadhusudhan