Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-highlight-text

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-highlight-text

A simple way to highlight text in React Native

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

react-native-highlight-text

A simple way to highlight text in React Native

Installation

npm install --save react-native-highlight-text
yarn add react-native-highlight-text

Usage

Highlight full text

import Highlight from 'react-native-highlight-text';

<Highlight highlightColor="blue" highlightTextColor="white">
  Highlight the full sentence!
</Highlight>;

Highlight specific parts of the text

import Highlight, { type HighlightSplit } from 'react-native-highlight-text';

const split: HighlightSplit[] = [
  [0, 9],
  [20, 25, 'green', 'orange'],
  [31, 40],
];

<Highlight highlightColor="blue" highlightTextColor="white" split={split}>
  Highlight different parts of a sentence!
</Highlight>;

Highlight using a RegEx

import Highlight from 'react-native-highlight-text';

<Highlight
  highlightColor="blue"
  highlightTextColor="white"
  highlightRegex={/(\d+)/g}
>
  Highlight a sentence with RegEx! 12.234.54.676
</Highlight>;

Highlight specific words

import Highlight from 'react-native-highlight-text';

<Highlight
  highlightColor="blue"
  highlightTextColor="white"
  wordMatch={['matching', 'words', 'sentence!']}
>
  Highlight matching words in a sentence!
</Highlight>;

Highlight component

If both split and highlightRegex props are not provided the full string will be highlighted

PropTypeDefaultDescription
highlightColorstringwhiteThe background color of the highlighted parts of the text
highlightTextColorstringblackThe text color of the highlighted parts of the text
styleStylePropStyle for the full text
highlightStyleStylePropStyle for the highlighted parts of the tex
childrenstringThe string to be shown
splitHighlightSplit[]A list of ranges to highlight. Created like [startIndex, endIndex, optional background color, optional text color]
highlightRegexRegExpA regex used to highlight parts of the text. g flag is required. Will overwrite split and wordMatch props
wordMatchstring[]A list of case-sensitive words to highlight. Will overwrite split prop

License

MIT

Keywords

FAQs

Package last updated on 16 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc