ColorPicker

Color selection control with hex input and visual picker. Displays a swatch that opens a full color picker on click.

Setup

import { ColorPicker } from '@fragments-sdk/ui';

Examples

Default

Basic color picker with label

Loading preview...

With Helper Text

Color picker with helper text

Loading preview...

Controlled

Controlled color picker that logs changes

Loading preview...

Multiple Pickers

Multiple color pickers for theme configuration

Loading preview...

Compact

Small size with swatch only (no input)

Loading preview...

Sizes

Different size variants

Loading preview...

Error State

Color picker with error styling

Loading preview...

Disabled

Disabled color picker

Loading preview...

Props

PropTypeDefaultDescription
labelstringNot setLabel text above the picker
valuestringNot setControlled color value in hex format (#RRGGBB)
defaultValuestring#000000Default color for uncontrolled usage
onChangefunctionNot setCalled with new color value when changed
onValueChangefunctionNot setAlias for onChange (Radix convention)
helperTextstringNot setHelper text below the picker (preferred)
descriptionstringNot setDeprecated alias for helperText
errorbooleanfalseShow error styling
disabledbooleanfalseDisable the color picker
sizeenumsmmdlgmdSize variant
showInputbooleantrueShow the hex input field

Usage Guidelines

When to use

  • Theme customization interfaces
  • Brand color selection
  • Design tool color inputs
  • User preference settings for colors

When not to use

  • Predefined color options only (use RadioGroup with swatches)
  • Simple color display without editing (use a colored Badge)
  • Color indication only (use semantic color tokens)

Best practices

  • Always provide a label to describe what the color is for
  • Use helperText to explain color usage or constraints
  • Consider providing color presets alongside the picker for common choices
  • Validate hex format (#RRGGBB) on input
Accessibility
  • Label is associated with the color input
  • Swatch button has appropriate aria-label
  • Color picker popup is keyboard accessible
  • Hex input allows direct text entry