1.1.1 • Published 4 years ago

highlight-search-text v1.1.1

Weekly downloads
29
License
MIT
Repository
github
Last release
4 years ago

highlight-search-text

Responsive component for highlighting text by keywords for React. May be useful for searching.

In this Demo you may get familiar with how the component works.

Installation

react version >= 16.8

npm install highlight-search-text --save

Import

import HighlightText from 'highlight-search-text';

Usage

<HighlightText
  search={search}
  text={text}
  highlightClassName="highlight"
  containerClassName="container"
  className="other"
  caseIgnore
  spaceIgnore
  startWord
  endWord
  fullWord
  all
/>

How it works

<HighlightText
  text="Once Upon A Time, In A Galaxy Far..."
  search="on"
  highlightClassName="highlight"
  containerClassName="container"
  className="other"
  caseIgnore
  all
>

<span class="container">
  <span class="highlight">On</span>
  <span class="other">ce Up</span>
  <span class="highlight">on</span>
  <span class="other"> A Time, In A Galaxy Far...</span>
</span>

Attributes

AttributesTypeDefaultDescription
searchstring''It’s what we are looking for
textstring''It’s where we are looking for
highlightClassNamestring''It’s the class of highlighted elements
containerClassNamestring''It’s the class of main container
classNamestring''It's the class of other elements
caseIgnorebooleanfalseThis option allows to search any piece of text ignoring its case-sensitivity(Uppercase/Lowercase).
spaceIgnorebooleanfalseThis option allows to search any piece of text ignoring leading and trailing spaces.
startWordbooleanfalseThis option allows to search any piece of text starting with the entered word exactly.
endWordbooleanfalseThis option allows to search any piece of text ending with the entered word exactly.
fullWordbooleanfalseThis option allows to search the whole word within the text. It brings only the very first match.
allbooleanfalseThis option allows to search the whole word with all its matches within the text.
1.1.1

4 years ago

1.1.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago