Skip to content

TrySound/css-color-component

 
 

Repository files navigation

<color-input>

A standalone web component color picker using colorjs.io and Preact signals.

  • One script import, one custom element tag
  • Colorspaces: srgb, hsl, hwb, lab, lch, oklch, oklab and wide-gamut RGB-like spaces
  • Popover UI with automatic positioning and Shadow DOM encapsulation

Try on CodePen or get it on NPM

Consider this as a beta or alpha build, needing battle testing, contributions and possibly a couple more features before being production ready

Usage

With CDN

<script src="https://unpkg.com/hdr-color-input"></script>

<color-input value="oklch(75% 75% 180)"></color-input>

API

  • Attributes: value, theme (auto|light|dark), no-alpha (boolean)
  • Properties: value, colorspace, theme, noAlpha, readonly: gamut, contrastColor
  • Methods: show(), close(), setAnchor(element)
  • Events: change, open, close

Attributes

no-alpha

When present, hides the alpha channel control from the color picker. The alpha value will still be preserved in the color value, but users won't be able to modify it through the UI.

<color-input value="oklch(75% 75% 180)" no-alpha></color-input>

Dev

  • Dev docs: npm run dev (serves docs/)
  • Build library: npm run build (outputs to dist/)
  • Tests: npm test

About

a modern color picker for the web with support for all spaces

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 93.6%
  • CSS 6.2%
  • JavaScript 0.2%