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

0.2.1 • Public • Published

react-higlighted

highlight matching text with react components

usage

import { highlight } from "react-higlighted";
 
const span = (text: string) => <span>{text}</span>;
const em = (text: string) => <em>{text}</em>;
 
function SearchResult(props: { text: string, query: string }) {
  return (
    <div className="result">
      {highlight(props.text, props.query, span, em)}
    </div>
  );
}

see more examples in tests

Readme

Keywords

none

Package Sidebar

Install

npm i react-highlighted

Weekly Downloads

3

Version

0.2.1

License

MIT

Last publish

Collaborators

  • barbuza