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

@zenuilabs/color-picker-react

v1.1.0

Published

A developer-friendly color picker with maximum customization ability also multiple variants and color format support

Readme

@zenuilabs/color-picker

A developer-friendly color picker component with TypeScript support, multiple interactive variants, and extensive customization options.

Live demo: https://color-picker.zenui.net/

showcase image

Contents


🚀 Features

  • Multiple color formats: hex, rgb, hsl, hsv, cmyk
  • Interactive variants:
    • Wheel picker
    • Hue slider
    • Hue box
  • Brightness/Value slider and fine-grained inputs
  • Format switcher and copy-friendly output
  • Favorites and quick presets
  • Color history and reset
  • Light/Dark themes with custom theme support
  • Fully typed with TypeScript
  • Accessible, keyboard-friendly interactions
  • Small and tree-shakeable

📦 Installation

Using npm:

npm install @zenuilabs/color-picker-react

⚡ Quick Start

import React, {useState} from 'react';
import {ColorPicker} from '@zenuilabs/color-picker-react';

export default function App() {
    const [color, setColor] = useState('#3B82F6');

    return (
        <div>
            <ColorPicker
                value={color}
                format="hex"
                variant="wheel"
                onChange={(next) => setColor(next.hex)}
            />
            <p>Selected: {color}</p>
        </div>
    );
}

🧪 Usage Examples

Basic (HEX, wheel):

import React, {useState} from 'react';
import {ColorPicker} from '@zenuilabs/color-picker-react';

function BasicExample() {
    const [color, setColor] = useState('#4F46E5');

    return (
        <ColorPicker
            value={color}
            format="hex"
            variant="wheel"
            onChange={(val) => setColor(val.hex)}
        />
    );
}

Use picker as inline:

import React, {useState} from 'react';
import {ColorPicker} from '@zenuilabs/color-picker-react';

function BasicExample() {
    const [color, setColor] = useState('#4F46E5');

    return (
        <ColorPicker
            value={color}
            format="hex"
            inline={true} // now the picker will render as inline
            variant="wheel"
            onChange={(val) => setColor(val.hex)}
        />
    );
}

Change format and access multiple representations:

import React, {useState} from 'react';
import {ColorPicker, type ColorFormat} from '@zenuilabs/color-picker-react';

function FormatExample() {
    const [format, setFormat] = useState<ColorFormat>('rgb');
    const [value, setValue] = useState('#22C55E');

    return (
        <div>
            <ColorPicker
                value={value}
                format={format}
                variant="hue-slider"
                onChange={(val, fmt) => {
                    // Persist a specific representation
                    setValue(fmt === 'hex' ? val.hex : val.hex);
                    // You can also handle the active format
                    setFormat(fmt);
                    console.log('As HEX:', val.hex);
                    console.log('As RGB:', val.rgb);
                    console.log('As HSL:', val.hsl);
                    console.log('As HSV:', val.hsv);
                    console.log('As CMYK:', val.cmyk);
                }}
            />
        </div>
    );
}

Hue box variant with presets, alpha, and history:

import React, {useState} from 'react';
import {ColorPicker} from '@zenuilabs/color-picker-react';

const presetColors = ['#FF6B6B', '#4ECDC4', '#45B7D1', '#F7B267', '#A78BFA'];

function AdvancedExample() {
    const [color, setColor] = useState('#F59E0B');

    return (
        <ColorPicker
            value={color}
            format="hsl"
            variant="hue-box"
            showAlpha
            showHistory
            showFormats
            showCopyButton
            presetColors={presetColors}
            maxHistory={15}
            onChange={(val) => setColor(val.hex)}
        />
    );
}

📚 API Reference

ColorPicker

A controlled React component. Provide a value and handle updates via onChange.

Props:

| Prop | Type | Default | Description | |-------------------|--------------------------------------------------|---------------------|---------------------------------------------------------------------| | value | string or ColorValue | — | Current color value (commonly HEX like #ffffff). | | format | ColorFormat | 'hex' | Active display/parse format: 'hex', 'rgb', 'hsl', 'hsv', or 'cmyk'. | | variant | ColorPickerVariant | 'wheel' | Visual variant: 'wheel', 'hue-slider', or 'hue-box'. | | theme | Themes or ColorPickerTheme | 'light' | Built-in theme ('light' or 'dark'). | | disabled | boolean | false | Disable all interactions. | | showAlpha | boolean | true | Enable alpha channel control and display when supported. | | showHistory | boolean | true | Track and display recently picked colors. | | showTitle | boolean | true | Show a title of the picker. | | showFormats | boolean | true | Show the format selector (HEX/RGB/HSL/HSV/CMYK). | | showCopyButton | boolean | true | Show a one-click copy to clipboard for the active format. | | presetColors | string[] | defaultPresetColors | Quick-access swatches displayed below the picker. | | maxHistory | number | 10 | Maximum number of items kept in color history. | | containerClasses | string | '' | Additional CSS classes for the root element. | | showColorInput | boolean | true | Show an input field to enter color values manually. | | containerStyle | React.CSSProperties | — | Inline styles for the root element. | | popupClasses | string | — | Additional CSS classes for the popup/colorContainer element. | | onChange | (value: ColorValue, format: ColorFormat) => void | — | Called on any color change. | | inline | boolean | false | Render the picker inline rather than in a popup. | | title | string | 'Color Picker' | Title text displayed on the picker. | | enableHueSlider | boolean | false | Enable the hue slider for variant that supports it. | | showPresets | boolean | true | Show preset color swatches. | | onFormatChange | (format: ColorFormat) => void | — | Called when the active format changes. | | onOpen | () => void | — | Callback fired when the color picker opens. | | brandColor | string | — | Optional brand color used for styling or highlighting. | | enableFavorite | boolean | false | Enable marking colors as favorites. | | enableShuffle | boolean | false | Enable shuffle button for random colors. | | onClose | () => void | — | Callback fired when the color picker closes. | | triggerRef | React.RefObject | — | External reference to trigger the picker popup. | | showDefaultButton | boolean | true | Show the default triggering button. |

Notes:

  • ColorValue includes every representation of the color (HEX, RGB, HSL, HSV, CMYK) so you can store or display any format without re-conversion.
  • The component is designed to be controlled; keeping value in your state is recommended.

Types

export type ColorFormat = 'hex' | 'rgb' | 'hsl' | 'hsv' | 'cmyk';
export type ColorPickerVariant = 'wheel' | 'hue-slider' | 'hue-box'
export type Themes = 'light' | 'dark';

export interface ColorValue {
    hex: string;
    rgb: { r: number; g: number; b: number; a?: number };
    hsl: { h: number; s: number; l: number; a?: number };
    hsv: { h: number; s: number; v: number; a?: number };
    cmyk: { c: number; m: number; y: number; k: number };
}

export interface ColorPickerTheme {
    primary: string;
    secondary: string;
    background: string;
    surface: string;
    text: string;
    textSecondary: string;
    border: string;
    borderHover: string;
    shadow: string;
}

export interface ColorPickerProps {
    value?: string;
    format?: ColorFormat;
    variant?: ColorPickerVariant;
    theme?: Themes;
    disabled?: boolean;
    inline?: boolean;
    showColorInput?: boolean;
    showTitle?: boolean;
    title?: string
    popupClasses?: string;
    showAlpha?: boolean;
    showHistory?: boolean;
    showFormats?: boolean;
    showCopyButton?: boolean;
    presetColors?: string[];
    maxHistory?: number;
    containerClasses?: string;
    containerStyle?: React.CSSProperties;
    onChange?: (color: ColorValue, format: ColorFormat) => void;
    onFormatChange?: (format: ColorFormat) => void;
    onOpen?: () => void;
    onClose?: () => void;
    enableHueSlider?: boolean;
    brandColor?: string;
    enableFavorite?: boolean;
    showPresets?: boolean;
    enableShuffle?: boolean;
    triggerRef?: React.RefObject<HTMLElement>;
    showDefaultButton?: boolean;
}

export interface UseColorPickerOptions {
    initialColor?: string;
    initialFormat?: ColorFormat;
    showAlpha?: boolean;
    maxHistory?: number;
}

Utilities

Useful helpers are available for parsing and formatting colors.

import {
    parseColor,
    formatColorValue,
    colorToValue,
    hsvToRgb,
    defaultPresetColors,
    type ColorValue,
    type ColorFormat,
} from '@zenuilabs/color-picker-react';
  • parseColor(input: string): ColorValue — Parses a string (HEX, RGB, HSL, etc.) into a full ColorValue.
  • formatColorValue(value: ColorValue, format: ColorFormat): string — Converts a ColorValue to a formatted string.
  • colorToValue(input: string | ColorValue): ColorValue — Normalizes arbitrary input to a ColorValue.
  • hsvToRgb(h: number, s: number, v: number): { r: number; g: number; b: number } — Low-level conversion utility.
  • defaultPresetColors: string[] — A ready-to-use list of common swatches.

🎨 Theming & Customization

You can switch between built-in themes.

Built-in theme:

<ColorPicker theme="dark"/>

Presets:

<ColorPicker presetColors={['#FF6B6B', '#4ECDC4', '#45B7D1']}/>

Alpha channel:

<ColorPicker showAlpha format="rgb"/>

History and favorites:

<ColorPicker showHistory showFavorites maxHistory={12}/>

✅ Compatibility / Requirements

  • React: 16.8 or newer (Hooks support required; 18+ recommended)
  • TypeScript: 5.x recommended (type definitions included)
  • Node.js: 18+ recommended
  • Module format: ESM-first
  • Browsers: Modern browsers with standard Canvas and Pointer Events support

⚠️ Note: Advanced features may rely on newer web APIs. Ensure your target browsers support them.


❓ FAQ

  • Controlled vs. uncontrolled?
    • The component is designed for controlled usage via value and onChange.
  • How to store colors?
    • Store ColorValue if you need multiple formats. Otherwise, store a single string (e.g., hex) and derive other formats when necessary.
  • Can I disable certain UI parts?
    • Use the boolean props like showFormats, showCopyButton, showHistory, etc., to tailor the UI.

🤝 Contributing

Contributions are welcome!

  • Fork the repository
  • Create a feature branch
  • Commit your changes with clear messages
  • Add/adjust tests where applicable
  • Submit a pull request describing your changes and rationale

Before submitting:

  • Ensure linting and type checks pass
  • Ensure the demo/playground still works
  • Update documentation if props or behavior changed

📄 License

MIT License


🆘 Support

  • Issues: open a ticket at https://github.com/zenui-labs/zenui-color-picker/issues/new
  • Contact: create an issue with details or reach us via your preferred channel

🧾 Type Definitions

This package ships with first-class TypeScript support. Types can be imported directly:

import type {
    ColorFormat,
    ColorValue,
    ColorPickerVariant,
    ColorPickerTheme,
} from '@zenuilabs/color-picker-react';

🛠️ Release & Build

  • The package is published on npm as @zenuilabs/color-picker-react.
  • ESM build with tree-shaking-friendly structure.
  • CSS: no global stylesheet required; theming is provided via props and CSS variables.

A Product of @zenui-labs