@pbroom/color-kit/reactColor

ColorProps

Props for Color: the UseColorOptions plus children.

interfaceimport type { ColorProps } from '@pbroom/color-kit/react';color.tsx:6
interface ColorProps extends UseColorOptions {
  children: ReactNode;
  defaultColor?: string | Color;
  state?: ColorState;
  onChange?: (event: ColorUpdateEvent) => void;
  defaultGamut?: GamutTarget;
  defaultView?: ViewModel;
}

Properties

childrenReactNode
Color components that share this provider's state.
defaultColor?string | Colordefault { l: 0.6, c: 0.2, h: 250, alpha: 1 }
Initial requested color in uncontrolled mode: any CSS color string parse accepts, or an OKLCH Color object. Ignored when state is set.
state?ColorState
Controlled full state. When set, the hook renders this state and reports updates through onChange instead of storing them.
onChange?(event: ColorUpdateEvent) => void
Called when a setter produces a new state. Fires synchronously inside the setter call (i.e. in your event handler, before React re-renders) in both controlled and uncontrolled modes, exactly once per effective update and never for no-op updates. Several setter calls in one tick compose: each event.next builds on the previous one, even in controlled mode before the new state prop arrives. Once React re-renders, later calls start from the state you committed, so an update you ignore is not carried into the next one.
defaultGamut?GamutTargetdefault 'display-p3'
Initial active display gamut in uncontrolled mode.
defaultView?ViewModeldefault 'oklch'
Initial active view model in uncontrolled mode.