Skip to content

Design system

Documentation

DesignComponents / ColorPicker

Components / ColorPicker

Stable

ColorPicker

Choose a six-digit hex value with a native swatch, inline validation, and a contrast sample.

On this page

Examples

Swatch and hex value

Choose a color visually or enter a six-digit hex value.

AaBlack or white text contrast: 4.92:1

Use a six-digit hex value.

Brand color picker with contrast preview

Validation feedback

An invalid typed draft shows an inline correction; the saved value stays unchanged.

AaBlack or white text contrast: 6.68:1

Use a six-digit hex value.

Color input with validation behavior

Disabled value

A locked value remains readable with its contrast sample.

AaBlack or white text contrast: 5.17:1

Use a six-digit hex value.

Disabled color value

Try the color picker

Explore the shared native swatch and hex input.

AaBlack or white text contrast: 4.77:1

Use a six-digit hex value.

Color picker property playground

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

Component API
PropTypeDefaultDescriptionConstraints
labelstringrequiredVisible accessible label for the hex entry.Provide a concise color purpose.
value / defaultValuestring#2563ebControlled color string or uncontrolled initial value.Use the six-digit #RRGGBB form.
onValueChange(value: string) => void—Called only for valid swatch or text updates.The feature owns persistence and product-specific validation.
disabledbooleanfalseDisables both editing controls.Native Input props such as name and required apply to the text value.

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.

  • Input handles other text values.
  • Colors documents semantic design tokens.