With Helper Text
Supporting line says where the colour will be used.
<ColorPicker
label="Primary Color"
defaultValue="#10b981"
helperText="This color will be used for buttons and links"
/>Selects a color through a visual picker and hexadecimal input.
<ColorPicker
label="Brand Color"
defaultValue="#3b82f6"
/>pnpm add @usefragments/uiImport styles once from @usefragments/ui/styles. See the installation guide for framework and theme setup.
react-colorful — Optional — renders the visual picker surface; the swatch and hex input work without it.pnpm add react-colorfulImport ColorPicker once, then compose its parts with dot notation.
ColorPicker.preloadSupporting line says where the colour will be used.
<ColorPicker
label="Primary Color"
defaultValue="#10b981"
helperText="This color will be used for buttons and links"
/>The parent owns the value and sees every change.
const [color, setColor] = React.useState('#10b981');
<ColorPicker label="Accent" value={color} onValueChange={setColor} />A stacked set reads as one palette.
<div style={{ display: 'flex', flexDirection: 'column', gap: '16px', maxWidth: '280px' }}>
<ColorPicker label="Primary" defaultValue="#3b82f6" />
<ColorPicker label="Secondary" defaultValue="#64748b" />
</div>Three swatch sizes: sm, md, lg.
<div style={{ display: 'flex', flexDirection: 'column', gap: '16px', maxWidth: '280px' }}>
<ColorPicker label="Small" defaultValue="#3b82f6" size="sm" />
<ColorPicker label="Medium (default)" defaultValue="#3b82f6" size="md" />
</div>Red border on the hex field, and the reason below it.
<ColorPicker
label="Brand Color"
defaultValue="#7c3aed"
invalid
errorMessage="This color fails contrast against the page background"
/>The value is shown and copyable but cannot change.
<ColorPicker label="Brand Color" defaultValue="#3b82f6" readOnly helperText="Set by your organisation" />Swatch will not open and the hex field will not accept typing.
<ColorPicker
label="Locked Color"
defaultValue="#64748b"
helperText="This color cannot be changed"
disabled
/>Prop | Type | Default | Description |
|---|---|---|---|
defaultValue | string | undefined | #000000 | Default color for uncontrolled usage |
disabled | boolean | undefined | false | Disable the color picker |
errorMessage | string | undefined | Not set | Words shown under the picker while it is invalid |
helperText | string | undefined | Not set | Helper text below the picker (preferred) |
invalid | boolean | undefined | false | Marks the value invalid: danger edges plus the error message |
label | string | undefined | Not set | Label text above the picker |
onValueChange | ((color: string) => void) | undefined | Not set | Called with the new #rrggbb value whenever it changes |
readOnly | boolean | undefined | false | Shows the value without letting it change |
size | ColorPickerSize | undefinedsmmd | md | Control size |
value | string | undefined | Not set | Controlled color value in hex format (#RRGGBB) |