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

@substrate-system/color-picker

v0.0.7

Published

Color picker web component

Downloads

642

Readme

color-picker

tests types module semantic versioning Common Changelog install size gzip size license

Color picker web component.

This was originally forked from Simonwep/pickr.

See a live demo

Install

npm i -S @substrate-system/color-picker

Example

It registers itself under the name color-picker. Just import, then you can use the tag in HTML. Set swatches to an array of valid CSS color strings, or use the default swatches.

JS

import '@substrate-system/color-picker'

const picker = document.querySelector('color-picker')

picker.swatches = ['#000', '#fff', '#ef4444', '#3b82f6']
picker.value = '#000'

// use the `.on` method for namespaced event
picker.on('change', (ev) => {
    console.log(ev.detail.value)   // selected color string
    console.log(ev.detail.index)   // index into swatches array
    console.log(ev.detail.source)  // 'pointer' | 'keyboard' | 'programmatic'
})

HTML

<color-picker id="picker"></color-picker>

API

Properties

| Property | Type | Description | |------------|-----------------|--------------------------------------| | swatches | string[] | Array of valid CSS color values. | | value | string\|null | The currently selected color string. | | disabled | boolean | Disables all interaction. |

You can also set value via HTML attribute:

<color-picker value="#ef4444"></color-picker>

Events

color-picker:change

Fired when the selected color changes. This is a namespaced event, as described here. You should use the .on method to listen for it:

const picker = document.querySelector('color-picker')

// `.on` will convert the given 'change' event to
// the correct namespaced event name, `color-picker:change`.
picker.on('change', ev => {
  // ...
})
interface ChangeDetail {
    value:string|null
    index:number|null
    source:'pointer'|'keyboard'|'programmatic'
}

Keyboard navigation

When a swatch has focus:

| Key | Action | |---------------------------------|----------------------------| | ArrowRight / ArrowDown | Select next swatch | | ArrowLeft / ArrowUp | Select previous swatch | | Space / Enter | Confirm active swatch |

Modules

This package ships ESM via the package.json exports field.

ESM

import '@substrate-system/color-picker'

Or import the component class:

import { ColorPicker } from '@substrate-system/color-picker'

CSS

Import CSS

import '@substrate-system/color-picker/css'

Or minified:

import '@substrate-system/color-picker/min/css'

Customize CSS

Override styles on the color-picker element:

color-picker .swatch {
    width: 32px;
    height: 32px;
    border-radius: 4px;
}

color-picker .swatch[aria-checked='true'] {
    border-color: hotpink;
}

Pre-built JS

Copy the minified bundle to your web server:

cp ./node_modules/@substrate-system/color-picker/dist/index.min.js ./public/picker.min.js

Then reference it in HTML:

<script type="module" src="./picker.min.js"></script>