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

@xsolla/xui-input-color

v0.187.3

Published

A compact inline control for previewing and editing a colour value — a colour swatch alongside an editable hex or RGB field, with optional transparency (alpha). Use it on its own, or as the inline trigger that opens a `ColorPicker`. Works on web and React

Readme

Input Color

A compact inline control for previewing and editing a colour value — a colour swatch alongside an editable hex or RGB field, with optional transparency (alpha). Use it on its own, or as the inline trigger that opens a ColorPicker. Works on web and React Native via XUIProvider themed contexts.

Installation

npm install @xsolla/xui-input-color

Imports

import { InputColor } from '@xsolla/xui-input-color';
import type {
  InputColorProps,
  InputColorType,
  InputColorSize,
} from '@xsolla/xui-input-color';

Quick start

const [color, setColor] = useState('#22A8C3');

<InputColor value={color} onChange={setColor} />;

API Reference

<InputColor>

| Prop | Type | Default | Description | | --- | --- | --- | --- | | value | string | — | Controlled colour as a hex string (e.g. #22A8C3; #RRGGBBAA when transparency is on). | | defaultValue | string | '#000000' | Initial value for uncontrolled usage. | | onChange | (value: string) => void | — | Change handler; always receives a hex string (8-digit when transparency is on). | | onSwatchClick | () => void | — | Fired when the swatch is activated. The swatch is interactive only when type="color" — use it to open a parent ColorPicker. Never called for other types. | | type | 'color' \| 'color-hex' \| 'color-rgb' \| 'hex' \| 'rgb' | 'color-hex' | Which controls render (see Types). | | transparency | boolean | false | Add an alpha (%) field and a transparency-aware swatch. | | size | 'xl' \| 'lg' \| 'md' \| 'sm' \| 'xs' | 'md' | Control size. | | label | string | — | Visible label shown above the control. | | id | string | auto | HTML id used for accessibility linking. | | aria-label | string | — | Accessible name when no visible label is present. | | testID | string | — | Test identifier. |

Inherits ThemeOverrideProps (themeMode, themeProductContext).

The canonical value is always a hex string, regardless of type. The hex and RGB fields are alternate editable representations of the same colour; editing either emits an updated hex through onChange.

Types

| type | Shows | | --- | --- | | color | Swatch only — acts as a trigger (onSwatchClick). | | color-hex | Swatch + hex field. | | color-rgb | Swatch + R / G / B fields. | | hex | Hex field only. | | rgb | R / G / B fields only. |

When transparency is on, an alpha (%) field is appended to every type and color gains it too.

Examples

Hex field (default)

const [color, setColor] = useState('#22A8C3');

<InputColor value={color} onChange={setColor} />;

RGB channels

const [color, setColor] = useState('#22A8C3');

<InputColor type="color-rgb" value={color} onChange={setColor} />;

Transparency (alpha)

const [color, setColor] = useState('#22A8C380');

<InputColor type="color-rgb" transparency value={color} onChange={setColor} />;

Sizes

<InputColor size="xl" defaultValue="#22A8C3" />
<InputColor size="md" defaultValue="#22A8C3" />
<InputColor size="xs" defaultValue="#22A8C3" />

Swatch as a ColorPicker trigger

type="color" renders the swatch alone; wire onSwatchClick to open a parent ColorPicker.

const [color, setColor] = useState('#22A8C3');
const [open, setOpen] = useState(false);

<InputColor
  type="color"
  value={color}
  onChange={setColor}
  onSwatchClick={() => setOpen(true)}
/>;

With a label

const [color, setColor] = useState('#22A8C3');

<InputColor value={color} onChange={setColor} label="Brand color" />;

Accessibility

  • The control is a role="group"; label it with label, aria-label, or an external aria-labelledby target.
  • Each editable field has an aria-label"Hex color value", "Red channel", "Green channel", "Blue channel", "Opacity percentage".
  • For type="color" the swatch is a <button aria-label="Open color picker">; for every other type it is a decorative preview marked aria-hidden (not focusable, not clickable).
  • Numeric fields (R / G / B, alpha) step by ±1 with the ArrowUp / ArrowDown keys, clamped to their range (0–255, or 0–100 for alpha).
  • A visually hidden role="status" / aria-live="polite" region announces colour changes to screen readers (e.g. "Color updated to #FF0000").
  • Editing updates the swatch live as you type; the value commits (and normalizes — shorthand expand, uppercase, clamp) on blur, Enter, or Tab.
  • The transparency checkerboard behind a translucent colour is rendered with CSS and is web only; the solid swatch and alpha split render on native.