DitherCharts

Color picker

Updated

ColorPicker is a color field that opens a 1984 Macintosh window: a pinstriped title bar over swatches, a hex field and the system picker, with the new color above the original. Each pick previews live, and Cancel puts the original back. Like the charts, it takes your theme's ink and paper, light or dark, and needs no Tailwind.

Example

Ink color

Locked

import "@/components/dithercharts/controls.css"
import { ColorPicker } from "@/components/dithercharts/color-picker"

<ColorPicker label="Ink color" defaultValue="#e23838" />
<ColorPicker label="Locked" defaultValue="#009cdf" disabled />

Install

Controls install with DitherCharts Pro. See Installation to log in, then import controls.css once, e.g. in your root layout.

npx dithercharts add color-picker

Props

It renders a native element, so every other attribute that element takes passes through.

ColorPicker props
PropTypeDefaultDescription
labelrequiredType ReactNodeDefault –The caption above the field and the window's title; also the field's accessible name.
hideLabelType booleanDefault falseKeeps the caption for screen readers only.
valueType stringDefault –The color as #rrggbb, for a controlled picker; pair it with onValueChange.
defaultValueType stringDefault "#000000"The color at first, for an uncontrolled picker.
onValueChangeType (value: string) => voidDefault –Called with each pick while the window is open; Cancel calls it again with the color from before.
swatchesType readonly string[]Default `MAC_SWATCHES`The swatch grid, eight to a row.
nameType stringDefault –The form field name; a hidden input carries the value.
disabledType booleanDefault false
classNameType stringDefault –