Halo
A round colour picker. The pad sets saturation and lightness; a short arc beside it sets hue.
@patternmode/halo
- Hue
- 16
- Saturation
- 48
- Lightness
- 69
Drag across the pad for saturation, up and down for lightness. Drag along the arc for hue.
Reference
States and variants
Put the hue arc on any side. The hex readout follows it.
Arc below
placement="bottom"Arc to the right
placement="right"Arc above
placement="top"No hex readout
showValue={false}
Install and use
Controlled. Hold the HSL value in state and pass it back in.
npm i @patternmode/haloimport { HaloPicker } from "@patternmode/halo";
import "@patternmode/halo/styles.css";
import type { HslColor } from "@patternmode/system";
export function AccentColorField() {
const [color, setColor] = useState<HslColor>({ h: 16, s: 48, l: 69 });
return (
<HaloPicker
aria-label="Accent color"
value={color}
onChange={setColor}
/>
);
}Core API
HaloPicker
Controlled HSL picker with a circular saturation/lightness pad and hue arc.
value- { h: number; s: number; l: number }Controlled HSL value.
onChange- (value: HslColor) => voidCalled with the next HSL value after pad or arc pointer input.
showValue- booleantrueShows the computed hex output beneath the picker.
label- string"Color"Hidden legend used when no aria-label is supplied.
Utilities
Pure helpers for custom readouts and non-standard renderers.
getHaloPadHandlePosition- (s, l) => { x, y }Maps saturation/lightness values to pad handle coordinates.
getHaloHueHandlePosition- (h) => { x, y }Maps hue to the smile arc handle coordinates.
Keyboard and accessibility
Both controls take arrow keys.
- Left, Right
- On the pad, nudge saturation.
- Up, Down
- On the pad, nudge lightness.
- Shift
- Takes larger steps.
- Hue
- The arc is a hidden slider, so arrow keys set hue from 0 to 359.
- label
- A hidden fieldset legend, used when there is no aria-label. Defaults to "Color".
Package
- Package
- @patternmode/halo
- Version
- 0.6.5
- Needs
- react, react-dom
- Licence
- MIT