ColorArea
A 2-D color field: saturation from left to right (mirrored in right-to-left layouts) and brightness from bottom to top, at the value's hue. ArrowLeft and ArrowRight move saturation by 1 %, ArrowUp and ArrowDown brightness; Shift with an arrow moves by 10, Page Up and Page Down move brightness by 10, and Home and End set saturation to 0 and 100. A press or drag (mouse, touch or pen) moves the thumb to the pointer. It is one Tab stop holding two sliders for assistive technology, "Saturation" and "Brightness", whose value texts start with their own channel and name the color; focus follows the axis a key moves, and unless the primary pointer is coarse (touch), only the slider with the Tab stop is exposed. Inside a ColorPicker, leave value and defaultValue out and it binds to the picker. Fluent's ColorArea, with value/onValueChange for its color/onChange.
Examples
Default
export const Default: Story = {};Controlled
#0f6cbd
export const Controlled: Story = {
render: function ControlledStory(args) {
const [color, setColor] = useState<HsvColor>({ h: 208, s: 0.92, v: 0.74 });
return (
<div className="flex w-64 flex-col gap-3">
<ColorArea
{...args}
value={color}
onValueChange={(next) => {
setColor(next);
args.onValueChange?.(next);
}}
/>
<ColorSlider value={color} onValueChange={setColor} />
<p className="text-wave-body-1 text-wave-foreground">{hsvToHex(color)}</p>
</div>
);
},
};Square
export const Square: Story = {
args: { shape: 'square' },
};Disabled
export const Disabled: Story = {
args: { disabled: true },
};Props
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
value | HsvColor | No | The color (Fluent's | |
defaultValue | HsvColor | No | the brand blue, `{ h: 208, s: 0.92, v: 0.74 }` (`#0f6cbd`) | Initial color for uncontrolled usage (also what a form reset restores). |
onValueChange | (value: HsvColor) => void | No | Called with the new color on every step (a key, a pointer move or assistive technology) that changes it (Fluent's | |
shape | 'square' | 'rounded' | No | 'rounded' |
|
labels | ColorAreaLabels | No | Texts of the area; bound to a ColorPicker, the picker's | |
disabled | boolean | No | false | Unavailable: both inputs are natively disabled, pointer presses are ignored and the area is dimmed. A bound area is also disabled while the picker's value is not a hex color. |
name | string | No | Form field name: the color is submitted as hex ( | |
form | string | No | Id of the form the area belongs to, when it is rendered outside that form. | |
required | boolean | No | Marks the hidden form input required (a color is always set, so it never blocks). A consumer | |
controlRef | React.Ref<HTMLInputElement> | No | Ref to the saturation | |
ref | React.Ref<HTMLDivElement> | No | Ref to the root | |
slotProps | { field?: SlotPart<'div'>; thumb?: SlotPart<'span'> } | No | Props for the elements the area draws inside its root, by part, merged into each part's own (Fluent UI's |
Any other prop is passed to the element it renders (HTMLDivElement).
Parts
fieldthumb
Stable class names
| Part | Class |
|---|---|
root | wave-color-area |
field | wave-color-area__field |
thumb | wave-color-area__thumb |