0.1.0 • Published 4 years ago

react-word-highlighter v0.1.0

Weekly downloads
3
License
GPL-3.0-or-later
Repository
github
Last release
4 years ago

React Word Highlighter

A simple react component to highlight the first substring ocorence in a given text. Styling, trimming and use of case sensitive is also possible for the highlighted text.

npm install -s react-word-highlighter

import React from 'react'
import HighlightText from 'react-word-highlighter'

export default () => {
  <HighlightText
    text="The Lord of the rings: the return of the king"
    highlight=" return "
    trimHighlight
    highlightStyle={
      {
        backgroundColor: '#ff0',
        fontWeight: 'bold',
        fontSize: 'xx-large',
        textDecoration: 'underline',
        textDecorationStyle: 'dashed',
      }
    }
  />
}