Skip to main content

ColorPicker

HSV-panel color picker: saturation / value board + hue / alpha sliders + hex / rgb input + predefined palette.

Basic usage​

Basic usage

Current color:#2B4C7C

import { LhColorPicker } from '@lh-ui/react'

export default function Demo() {
return (
<LhColorPicker
defaultValue="#2B4C7C"
predefine={['#2B4C7C', '#8C2F3B', '#3B6E4F']}
showAlpha
clearable
/>
)
}

ColorPicker Props​

PropDescriptionTypeOptionsDefault
value / defaultValueColor value (controlled / uncontrolled, hex or rgb() string)string——
onChangeColor changed (output follows format)(value: string) => void——
onClearClear button clicked (fires when emptied)() => void——
formatOutput formatLhColorFormat'hex' | 'rgb''hex'
showAlphaAlpha channel (outputs 8-digit hex / rgba())boolean—false
predefinePredefined palettestring[]——
sizeSizeLhComponentSize'small' | 'medium' | 'large''medium'
disabledDisabledboolean—false
clearableClear (empty) buttonboolean—false
placeholderPlaceholder (when empty)string—''
ariaLabelAccessible name (falls back to locale pack colorPicker.label)string——
sxShorthand layout propsSxProps——

Ref (LhColorPickerInstance)​

MethodDescription
open()Open the panel
close()Close the panel
Interaction details

Trigger Enter / Space toggles, Esc closes; sliders follow the APG slider pattern (arrow keys step, Shift for larger steps); the panel is portaled to body and positioned by useLhPopper (flip / clamp), and keyboard events inside the panel do not bubble to the trigger.

Format normalization

Output values are normalized to lowercase hex / rgba(); unparseable input reverts the field to the current display value and never emits an invalid value.

Styles​

import '@lh-ui/react/style/color-picker'