
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
react-native-highlight-text
Advanced tools
A simple way to highlight text in React Native
npm install --save react-native-highlight-text
yarn add react-native-highlight-text
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>;
If both split and highlightRegex props are not provided the full string will be highlighted
Prop | Type | Default | Description |
---|---|---|---|
highlightColor | string | white | The background color of the highlighted parts of the text |
highlightTextColor | string | black | The text color of the highlighted parts of the text |
style | StyleProp | Style for the full text | |
highlightStyle | StyleProp | Style for the highlighted parts of the tex | |
children | string | The string to be shown | |
split | HighlightSplit[] | A list of ranges to highlight. Created like [startIndex, endIndex, optional background color, optional text color] | |
highlightRegex | RegExp | A regex used to highlight parts of the text. g flag is required. Will overwrite split and wordMatch props | |
wordMatch | string[] | A list of case-sensitive words to highlight. Will overwrite split prop |
MIT
FAQs
A simple way to highlight text in React Native
The npm package react-native-highlight-text receives a total of 19 weekly downloads. As such, react-native-highlight-text popularity was classified as not popular.
We found that react-native-highlight-text demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.