Prism Picker
A hue picker built on optics: a white beam refracts through a glass prism (Snell's law, a Cauchy dispersion curve), a dial turns the prism, and the wavelength that leaves through a fixed exit slit is the colour, from the CIE 1931 observer through OKLCH to sRGB. UI SDK's slider in nanometres, painted additively on a canvas only when it changes, with setWavelength and setHue for agents.
Example
- Hex
- #00deff
- cyan
- 480 nm
- 213° OKLCH
- 188° HSL
- −8.1°
Turn the prism to pick a colour.
Inspired by @ctatedev (opens in a new tab)
Installation
Usage
Reach for it where picking a hue is part of the experience, like a brand or theme playground: the light is physics, not decoration. For any colour, alpha or a typed value, use ColorPicker.
API reference
PrismPicker
| Prop | Type | Default |
|---|---|---|
labelrequiredThe accessible name of the picker as a whole. | string | – |
valueThe picked wavelength in nm, a whole number from 380 to 700. Pass it to control the picker. | number | – |
defaultValue | number | 520 |
onValueChangeRuns on every step of a drag or a key, with UI SDK's slider details (`reason`, `source`, `cancel()`). | (value: number, details: SliderValueChangeDetails) => void | – |
onValueCommitRuns once a drag or a key press that changed the value ends, for saving. | (value: number) => void | – |
onColorChangeRuns with the colour on every change, with the same details. | (color: PrismColor, details: SliderValueChangeDetails) => void | – |
disabled | boolean | false |
nameSubmits the wavelength under this name in a form. | string | – |
labelsOverrides any label; `names` overrides colour names one by one. | Partial<Omit<PrismPickerLabels, "names">> & { names?: Partial<ColourNames> } | – |
classNameClasses for the root; a function gets the picker's state. | string | ((state: PrismPickerState) => string | undefined) | – |
onPaintCalled with each canvas paint's duration in ms, for measuring. | (milliseconds: number) => void | – |
Other exports
prismPickerLabelsprismPickerangleAtcolourAtcolourNamedialDegreesreadingAtsceneTiltwavelengthAtAnglecolourAtHuecieXyzexitAnglehueAtWavelengthluminousEfficiencymaxWavelengthminWavelengthprismRadiusprismVerticesredEndHuerefractiveIndexrotationForWavelengthrotationRangeslitDirectionspectralHuetracevioletHuewavelengthAtHuescaleAtwavelengthAtScalebeamHeightlayoutForpaintSceneringRadiusstageCentreusePrismPickerScenetype PrismColortype PrismPickerLabelstype PrismPickerPropstype PrismPickerStatetype PrismPickerOptionstype PrismSlidertype ColourNamestype Readingtype PickedColourtype Rgbtype Tracetype Vectype Layouttype SceneTargetstype PrismCanvasesAccessibility
- The dial is a slider in nanometres: arrows step 1 nm, Page Up and Page Down 10, Home and End go to 380 and 700, and it reads as "470 nm, blue".
- Touch takes the ring and 24px either side of it, and the prism inside; the page scrolls everywhere else. The knob keeps a 44px hit area.
- Under reduced motion the prism jumps instead of gliding; the light stays.
- The stage is dark in every theme, so the focus ring on it is white; the readout below follows the theme.
Agent actions
Agents find it by its label and call setWavelength (380 to 700) or setHue (OKLCH degrees); a magenta or purple hue fails the step with why, since no single wavelength shows it.
Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.