Examples
Swatch and hex value
Choose a color visually or enter a six-digit hex value.
Use a six-digit hex value.
Brand color picker with contrast preview
import { ColorPicker } from "@phuctech/ui/components/color-picker";
export function Example() {
return <ColorPicker label="Brand color" defaultValue="#2563eb" />;
}
Validation feedback
An invalid typed draft shows an inline correction; the saved value stays unchanged.
Use a six-digit hex value.
Color input with validation behavior
import { ColorPicker } from "@phuctech/ui/components/color-picker";
export function Example() {
return <ColorPicker label="Accent color" defaultValue="#ea580c" />;
}
Disabled value
A locked value remains readable with its contrast sample.
Use a six-digit hex value.
Disabled color value
import { ColorPicker } from "@phuctech/ui/components/color-picker";
export function Example() {
return <ColorPicker label="Locked color" value="#15803d" disabled />;
}
Try the color picker
Explore the shared native swatch and hex input.
Use a six-digit hex value.
Color picker property playground
import { ColorPicker } from "@phuctech/ui/components/color-picker";
export function Example() {
return <ColorPicker label="Interface accent" defaultValue="#7c3aed" />;
}
Usage
import { ColorPicker } from "@phuctech/ui/components/color-picker";
<ColorPicker label="Brand color" value={color} onValueChange={setColor} />The stable value contract is a #RRGGBB string. Invalid text remains a local draft and does not replace the last valid value. This control does not edit design tokens or theme configuration.
API
Accessibility
The native color input has its own accessible name, and the visible text label names the hex field. Invalid values set aria-invalid, reference the inline error, and announce the correction. The contrast preview reports the stronger black-or-white text contrast for the selected background; it is informational and does not guarantee that surrounding content meets every contrast requirement.