React Answers

How to highlight text using React?

Spread the love

To highlight text using React, we can use the react-highlighter module.

To install it, we run

npm i react-highlighter

Then we write

const Highlight = require("react-highlighter");

<Highlight search="brown">
  The quick brown fox jumps over the lazy dog

to use the Highlight component to highlight 'brown' in 'The quick brown fox jumps over the lazy dog'.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *