ColorPicker
HSV-panel color picker: saturation / value board + hue / alpha sliders + hex / rgb input + predefined palette.
Basic usage
Basic usage
#2b4c7c
#8c2f3b
#3b6e4f
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
| Prop | Description | Type | Options | Default |
|---|---|---|---|---|
| value / defaultValue | Color value (controlled / uncontrolled, hex or rgb() string) | string | — | — |
| onChange | Color changed (output follows format) | (value: string) => void | — | — |
| onClear | Clear button clicked (fires when emptied) | () => void | — | — |
| format | Output format | LhColorFormat | 'hex' | 'rgb' | 'hex' |
| showAlpha | Alpha channel (outputs 8-digit hex / rgba()) | boolean | — | false |
| predefine | Predefined palette | string[] | — | — |
| size | Size | LhComponentSize | 'small' | 'medium' | 'large' | 'medium' |
| disabled | Disabled | boolean | — | false |
| clearable | Clear (empty) button | boolean | — | false |
| placeholder | Placeholder (when empty) | string | — | '' |
| ariaLabel | Accessible name (falls back to locale pack colorPicker.label) | string | — | — |
| sx | Shorthand layout props | SxProps | — | — |
Ref (LhColorPickerInstance)
| Method | Description |
|---|---|
| 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'