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

@io-gui/colors

v2.0.0-alpha.3

Published

A set of color pickers and editors for Io-Gui.

Downloads

239

Readme

@io-gui/colors

Color picker components for Io-Gui with RGB, HSL, and HSV color model support.

See live examples here

Overview

IoColorPicker
└── IoColorPanelSingleton (overlay)
    ├── IoColorSlider (sv - 2D saturation/value)
    ├── IoColorSlider (h - hue)
    └── IoColorSlider (a - alpha, optional)

IoColorRgba
├── IoColorSwatch
└── IoColorSlider[] (r, g, b, a)

Color Value Format

All color components use RGBA objects with values normalized to 0-1:

type ColorValue = {
  r: number  // 0-1
  g: number  // 0-1
  b: number  // 0-1
  a?: number // 0-1, optional
}

Elements

IoColorPicker

Compact color picker that expands IoColorPanelSingleton on click.

type IoColorPickerProps = {
  value: ColorValue  // Color object with r, g, b, a properties
}

Key behaviors:

  • Displays an IoColorSwatch preview
  • Expands panel singleton on click, Enter, or Space
  • Panel is positioned using nudge() utility

IoColorSwatch

Displays a colored square with transparency checkerboard background.

type IoColorSwatchProps = {
  value: ColorValue
}

IoColorSlider

Generic color slider wrapper that renders channel-specific sliders.

type IoColorSliderProps = {
  value: ColorValue
  channel: 'r' | 'g' | 'b' | 'a' | 'h' | 's' | 'v' | 'l' | 'hs' | 'sv' | 'sl'
  step?: number       // defaults to 0.01
  vertical?: boolean  // vertical orientation
}

Available channels: | Channel | Type | Description | |---------|------|-------------| | r | 1D | Red (0-1) | | g | 1D | Green (0-1) | | b | 1D | Blue (0-1) | | a | 1D | Alpha (0-1) | | h | 1D | Hue (0-1, maps to 0-360°) | | s | 1D | Saturation (0-1) | | v | 1D | Value/Brightness (0-1) | | l | 1D | Lightness (0-1) | | hs | 2D | Hue + Saturation | | sv | 2D | Saturation + Value | | sl | 2D | Saturation + Lightness |

IoColorRgba

Expanded color editor with swatch and individual RGBA sliders.

type IoColorRgbaProps = {
  value: ColorValue
}

IoColorPanelSingleton

Global singleton overlay containing the expanded color picker UI. Automatically appended to IoOverlaySingleton.

Key behaviors:

  • Shows SV (saturation/value) 2D slider + H (hue) vertical slider
  • Alpha slider appears only when value.a is defined
  • Collapses on Escape, Enter, or Space

Color Model Conversions

The package exports conversion utilities:

import { rgb2hsl, hsl2rgb, rgb2hsv, hsv2rgb } from 'io-colors'

// RGB arrays use 0-255 range
// HSL/HSV arrays use: [0-360, 0-100, 0-100]

const hsl = rgb2hsl([255, 128, 64])  // [20, 100, 62.5]
const rgb = hsl2rgb([20, 100, 62.5]) // [255, 128, 64]

Data Flow

User drags slider
    ↓
IoColorSlider._onValueInput()
    ↓
Updates internal HSV/HSL → converts to RGB → updates value object
    ↓
Dispatches 'value-input' event
    ↓
IoColorBase.valueMutated() triggers re-render

Events

| Event | Dispatched By | Payload | Purpose | |-------|---------------|---------|---------| | value-input | IoColorSlider, IoColorPanel | { property: 'value', value } | Color value changed |

Edge Cases

Hue Preservation

When saturation or value reaches 0, the hue information would normally be lost during RGB conversion. IoColorBase preserves the original hue:

  • Hue at 0° or 360° retains previous hue value
  • Saturation at 0 retains previous hue
  • Value/Lightness at 0 or 100 retains previous hue and saturation

Alpha Channel

The alpha slider only renders when value.a is defined. Components handle both RGB and RGBA values:

// RGB only - no alpha slider
picker.value = { r: 1, g: 0.5, b: 0 }

// RGBA - alpha slider appears
picker.value = { r: 1, g: 0.5, b: 0, a: 0.8 }

WebGL Rendering

Color sliders extend IoSlider and IoSlider2d which use WebGL for rendering. Channel-specific GLSL shaders compute gradient colors dynamically based on the current color state.