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

@mdcrty/color

v0.2.2

Published

A zero-dependency React colour picker and converter component.

Readme

@mdcrty/color

A zero-dependency React colour picker and converter. Converts between hex, RGB, HSL, HSV, LAB, LCH, OKLCH, HWB, and CMYK. Includes a visual picker (gradient square + hue + alpha bars), per-format text inputs with copy buttons, and an optional full-page ripple background mode.

Demo

mediocrity.media/color

Installation

npm install @mdcrty/color

Peer dependencies: react >= 18, react-dom >= 18

Usage

import { Color } from "@mdcrty/color";

// Colour converter with input fields and picker
<Color input defaultColor="#E6D6B8" maxWidth={500} />

// Touch ripple only — no input UI, clicking the background cycles random colours
<Color touch />

// Both together
<Color touch input defaultColor="#E6D6B8" maxWidth={500} />

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | input | boolean | false | Render the input fields and picker UI | | touch | boolean | false | Enable background ripple on page click | | defaultColor | string | "#FFFFFF" | Starting colour (any valid CSS colour) | | inputs | string[] | all formats | Which format inputs to show. Subset of MOCKDATA | | maxWidth | number \| string | 500 | Max width of the content panel | | className | string | — | Extra class on the outer wrapper | | classNames | ColorClassNames | — | Per-slot class overrides (see below) |

inputs values

The MOCKDATA export lists all supported formats in default order:

import { MOCKDATA } from "@mdcrty/color";
// ["hex", "rgb", "hsl", "hsv", "lab", "lch", "oklch", "hwb", "cmyk"]

Pass a subset to show only specific formats:

<Color input inputs={["hex", "rgb", "hsl"]} />

Slot overrides (classNames)

Use classNames to apply additional CSS classes to specific parts of the component without fighting :global() overrides:

import type { ColorClassNames } from "@mdcrty/color";

const myClasses: ColorClassNames = {
  inner: styles.myPanel,
  trigger: styles.myTrigger,
  input: styles.myInput,
};

<Color input classNames={myClasses} />

| Slot | Element | |------|---------| | inner | Outer content wrapper (supplements className) | | trigger | The rainbow/colour trigger button | | picker | The collapsible picker panel | | inputGrid | Grid wrapping all format inputs | | input | Each format text input | | copyBtn | Copy-to-clipboard button beside each input | | squareCursor | The circular cursor ring on the gradient square | | hueThumb | The circular thumb on the hue bar | | alphaThumb | The circular thumb on the alpha bar | | sliderThumb | The circular thumb on each channel slider |

The four circle slots are handy for theming the picker against dark hosts — the built-in circles are white. The squareCursor is a ring (style its border-color); the three thumbs are discs (style their background):

/* my-page.module.css — grey circles when the host is in dark mode */
:global(body.dark) .thumb {
  background: #d5d2ca;
}
:global(body.dark) .cursor {
  border-color: #d5d2ca;
}
<Color
  input
  classNames={{
    squareCursor: styles.cursor,
    hueThumb: styles.thumb,
    alphaThumb: styles.thumb,
    sliderThumb: styles.thumb,
  }}
/>

Dark / light mode

The component sets body.light or body.dark based on the perceived brightness of the current colour and includes built-in CSS rules for both states. In touch mode this also updates document.body.style.backgroundColor and the <meta name="theme-color"> tag on each ripple.

ColorObject

The underlying colour conversion class is also exported for direct use:

import { ColorObject } from "@mdcrty/color";

const color = new ColorObject("#E6D6B8");
console.log(color.rgb.print()); // rgb(230, 214, 184)
console.log(color.hsl.print()); // hsl(38, 44%, 81%)
console.log(color.lab.print()); // lab(87, 2, 16)

Links

  • Demo: https://mediocrity.media/color/
  • GitHub: https://github.com/mdcrty/mdcrty-packages
  • npm: https://www.npmjs.com/package/@mdcrty/color