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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@choiceform/colors

v0.3.33

Published

A modern React color system

Downloads

102

Readme

@choiceform/colors

A powerful color management and picker component library for design systems.

Features

  • 🎨 Rich color picker components
  • 🔍 Support for multiple color formats (HEX, RGB, HSL, HSB)
  • 🌈 Gradient, solid color, pattern, and image support
  • 🧩 Highly customizable extension capabilities
  • 📚 Easy-to-integrate API
  • 🔌 Dynamic tabs extension system
  • 📋 Color contrast checking functionality

Installation

npm install @choiceform/colors

or

yarn add @choiceform/colors

Basic Usage

Simple Color Picker

import { useState } from "react"
import { ColorPickerPopover, ColorSolidPaint } from "@choiceform/colors"
import type { RGB } from "@choiceform/colors"

function ColorPickerExample() {
  const [color, setColor] = useState<RGB>({ r: 66, g: 133, b: 244 })
  const [alpha, setAlpha] = useState<number>(1)
  const [open, setOpen] = useState<boolean>(false)

  return (
    <ColorPickerPopover
      open={open}
      onOpenChange={setOpen}
      solidPaint={
        <ColorSolidPaint
          color={color}
          alpha={alpha}
          onColorChange={setColor}
          onAlphaChange={setAlpha}
        />
      }
    >
      <div
        className="h-12 w-12 cursor-pointer rounded"
        style={{
          backgroundColor: `rgba(${color.r}, ${color.g}, ${color.b}, ${alpha})`,
        }}
        onClick={() => setOpen(true)}
      />
    </ColorPickerPopover>
  )
}

Gradient Picker

import { useState } from "react"
import { ColorPickerPopover, ColorSolidPaint, ColorGradientsPaint } from "@choiceform/colors"
import type { RGB, GradientPaint } from "@choiceform/colors"

function GradientPickerExample() {
  const [color, setColor] = useState<RGB>({ r: 66, g: 133, b: 244 })
  const [gradient, setGradient] = useState<GradientPaint>({
    type: "GRADIENT_LINEAR",
    gradientStops: [
      { id: "1", position: 0, color: { r: 255, g: 0, b: 0 }, alpha: 1 },
      { id: "2", position: 1, color: { r: 0, g: 0, b: 255 }, alpha: 1 },
    ],
    gradientTransform: [
      [1, 0, 0],
      [0, 1, 0],
    ],
  })

  // ...
}

Advanced Features

Dynamic Tabs System

The Colors library provides a powerful dynamic tabs system that allows you to extend the color picker's functionality:

import { ColorPickerPopover, ColorSolidPaint } from "@choiceform/colors"

function CustomTabsExample() {
  // ...

  // Custom tab content
  const customPaletteContent = (
    <div className="p-4">
      <h3>Custom Palette</h3>
      {/* Custom content */}
    </div>
  )

  // Define additional tabs
  const additionalTabs = [
    {
      value: "CUSTOM_PALETTE",
      label: "Palette",
      content: customPaletteContent,
    },
  ]

  return (
    <ColorPickerPopover
      additionalTabs={additionalTabs}
      solidPaint={<ColorSolidPaint /* ... */ />}
      // ...other properties
    />
  )
}

Features Configuration

You can control the functionality of the color picker through the features property:

<ColorPickerPopover
  features={{
    containerWidth: 240,
    spaceDropdown: true,
    alpha: true,
    hex: true,
    rgb: true,
    hsl: true,
    hsb: true,
    nativePicker: true,
    presets: true,
    pickerType: true,
    custom: true,
    paintsType: true,
    solid: true,
    gradient: true,
    pattern: true,
    image: true,
    checkColorContrast: true,
  }}
  // ...other properties
/>

Color Contrast Checking

Support for checking color accessibility contrast:

<ColorPickerPopover
  checkColorContrast={{
    backgroundColor: { r: 255, g: 255, b: 255 },
    foregroundColor: color,
    foregroundAlpha: alpha,
    level: "AA",
    category: "normal-text",
    // ...other configurations
  }}
  // ...other properties
/>

API Reference

ColorPickerPopover

The main color picker component.

| Property | Type | Default | Description | | -------------------- | ------------------------------- | ---------- | ---------------------------------- | | open | boolean | - | Control the popup state | | onOpenChange | (open: boolean) => void | - | Popup state change callback | | pickerType | string | "CUSTOM" | Picker type | | onPickerTypeChange | (type: string) => void | - | Picker type change callback | | paintsType | Paint["type"] | "SOLID" | Paint type | | onPaintsTypeChange | (type: Paint["type"]) => void | - | Paint type change callback | | solidPaint | ReactNode | - | Solid paint component | | gradientPaint | ReactNode | - | Gradient paint component | | additionalTabs | TabItem[] | [] | Additional tabs configuration | | features | PickerFeatures | - | Feature configuration | | checkColorContrast | ColorContrast | - | Color contrast check configuration | | ...others | PopoverProps | - | Properties inherited from Popover |

Related Types

// Tab item
interface TabItem {
  value: string
  label: string
  content: ReactNode
}

// Features configuration
interface PickerFeatures {
  containerWidth?: number
  spaceDropdown?: boolean
  alpha?: boolean
  hex?: boolean
  rgb?: boolean
  hsl?: boolean
  hsb?: boolean
  nativePicker?: boolean
  presets?: boolean
  variables?: boolean
  styles?: boolean
  pickerType?: boolean
  custom?: boolean
  paintsType?: boolean
  solid?: boolean
  gradient?: boolean
  pattern?: boolean
  image?: boolean
  checkColorContrast?: boolean
}

Contributing

Contributions to @choiceform/colors through PRs and Issues are welcome. Please ensure you follow the project's code style and testing standards before submitting.

License

MIT