npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-highlight-colors

v1.0.2

Published

React component that allows users to select text and highlight it in whichever color they choose.

Readme

react-highlight-colors

demo

React component that allows users to select text and highlight it in whichever color they choose. Uses juliankrispel's Selection Popover.

Installation

npm install react-highlight-colors

Usage

Importing Component

import Highlighter from 'react-hightlight-colors'

Simplest Usage

The simplest way of getting started is by just including the component with text you want to make highlightable.

<Highlighter text={yourText} />

Exporting Highlighted Text

If you wanna store the highlighted data you must pass in a callback function to the export prop.

Here is one way of using the export prop:

<Highlighter text={yourText} export={(highlightedText) => {
  this.setState({
    exportedText: highlightedText
  })
}} />

Importing Highlighted Text

Once you have exported your text and want to import it back to your Highlighter component, just set the import prop to True.

Colors

Format

In order to choose colors for the highlighter component you must pass in a list of color strings in one of the following formats:

'#FFF'
'#FFFFFF'
'rgb(255,255,255)'

Color List

Here is an example of how you can pass in a list of colors.

const chosenColors = [
 '#B80000', 
 '#DB3E00', 
 '#008B02', 
 '#FC0',
 'rgb(109,163,182)'
]
<Highlighter text={yourText} colors={chosenColors} />

This is the result of the code above.

Unlabeled Colors

Labeled Colors

You can add labels to your colors, by modifying the list of colors and adding the label after each color in its own list.

Here is an example of a color list with labels:

const labeledColors = [
  ['#B80000', 'Label 1'], 
  ['#DB3E00',  'Label 2'],
  ['#008B02'  'Label 3'],
  ['#FC0', 'Label 4'],
  ['rgb(109,163,182)', 'Label 5'],
]
<Highlighter text={yourText} colors={labeledColors} />

Result:

Labeled Colors

Props

| Property | Type | Is Required | Default Value | Description | | - | - | - | - | - | | text | PropTypes.string | required | n/a | The text that will be highlightable. | | style | PropTypes.object | optional | null | CSS style applied to text. | | colors | PropTypes.array | optional | ['#B80000', '#DB3E00', '#FCCB00', '#008B02', '#006B76', '#1273DE', '#004DCF', '#5300EB', '#EB9694', '#FAD0C3', '#FEF3BD', '#C1E1C5', '#BEDADC', '#C4DEF6', '#BED3F3', '#D4C4FB'] | Color options for the highlighter. | | export | PropTypes.func | optional | null | Callback function that passes the exported format of the text. Callback is called each time text is highlighted. | | import | PropTypes.bool | optional | false | Boolean variable which determines if the text being passed in is imported. Text must be exported before being able to import it. | | cols | PropTypes.number | optional | 8 | Number of columns of colors per row in color popover. |

License

MIT © Jonathan