ColorPicker
Choose colors with a spectrum, brightness slider and channel fields, with optional opacity.
Usage
<script>
import { ColorPicker } from 'fluentui-svelte';
</script>
<ColorPicker defaultValue="#0078d4" /> Shapes
Use shape with the shared Shapes options: rounded (default), square or circular. All expose the same keyboard controls.
Horizontal orientation
Set orientation="horizontal" to place the channel fields beside the spectrum and use vertical sliders.
Opacity
Enable alpha to edit opacity. The preview shows the color over a checkerboard and against its opaque equivalent. User edits include the alpha channel in the hexadecimal value.
RGB and HSV fields
Use format="hsv" to start with hue, saturation and brightness fields. Switching between RGB and HSV preserves the selected color.
Collapsed
Use collapsed to hide channel fields initially. The expansion button exposes its state with aria-expanded; bind:collapsed lets the application control it.
Controlled value
Use bind:value to read and update the selected color. External CSS colors synchronize the spectrum, preview and fields. User edits produce hexadecimal strings.
Using with Label
Wrap the picker in Label to name the group. For a separate label, use aria-labelledby; otherwise provide aria-label or label.
Forms and reset
The field submits a single color under name. Native validation supports required and pattern. Reset restores defaultValue; disabled fields are excluded from submission.
Disabled
Use disabled to disable interaction and form submission. Use readonly to preserve submission while preventing edits.
Keyboard and accessible names
Tab reaches the hue and saturation ranges, brightness and opacity sliders, and channel fields. In the spectrum, Left and Right move the marker horizontally; Up and Down move it vertically. Both coordinates are announced. Home and End select the focused range's limits. Customize channelLabels, label, formatLabel, moreLabel, lessLabel and validationMessage for your language. Native oninput and onchange report edits through the form field; ref exposes that field and wrapperAttributes styles the visible group.
Input constraints
RGB channels accept integers from 0 to 255; hue from 0 to 360, and saturation, brightness and opacity from 0 to 100. Out-of-range values are clamped. Empty channels restore their selected value on blur. Hex accepts 3 or 6 digits, and 4 or 8 with alpha. The # prefix is optional. Invalid or incomplete hexadecimal edits restore the selected color.
Component Props
| Name | Type | Default | Description |
|---|---|---|---|
channelLabels | Partial< Record<'hue' | 'saturation' | 'brightness' | 'opacity' | 'red' | 'green' | 'blue' | 'hex', string> > | Accessible channel labels, overriding the English defaults. | |
value bindable | string | The CSS color submitted by the field. User edits produce hexadecimal colors. | |
defaultValue | string | '#ffffff' | Initial color and the value restored by a native form reset. |
shape | 'circular' | 'rounded' | 'square' | 'rounded' | Shape of the hue/saturation spectrum. |
orientation | 'vertical' | 'horizontal' | 'vertical' | Arrangement of the spectrum, sliders and fields. |
collapsed bindable | boolean | Hides the channel fields until the user expands them. | |
format bindable | 'rgb' | 'hsv' | 'rgb' | Channel fields displayed in the editor. |
alpha | boolean | Enables the opacity slider and alpha channel. | |
label | string | 'Color picker' | Accessible name of the picker. |
formatLabel | string | 'Color format' | Accessible name of the channel format selector. |
moreLabel | string | 'More' | Label of the expansion control. |
lessLabel | string | 'Less' | Label of the collapse control. |
validationMessage | string | Message used for an invalid CSS color. | |
onColorChange | (value: string) => void | Reports a user color edit. | |
ref bindable | HTMLInputElement | null | Native form field reference. | |
wrapperRef bindable | HTMLDivElement | null | Visible picker reference. | |
wrapperAttributes | HTMLAttributes<HTMLDivElement> | Attributes for the visible picker. | |
NativeFieldAttributes<HTMLInputAttributes> without value, defaultValue, type, size, children, on: |

