ColorSlider
A slider for one channel of an HSV color: hue (the default), saturation or brightness (channel="value"), horizontal (mirrored in right-to-left layouts) or vertical (bottom to top). The arrow keys move by 1 (hue in degrees, the others in percent), Shift with an arrow and Page Up or Page Down by 10, Home and End to the ends. It is named by aria-label, else the surrounding Field's label, else "Hue", "Saturation" or "Brightness"; a hue slider's value text names the color ("210°, blue"). Inside a ColorPicker, leave value and defaultValue out and it binds to the picker. ref reaches the range input, as the naming, validation and focus props do; className, style and data-* stay on the root (slotProps.root.ref reaches it). Fluent's ColorSlider, with value/onValueChange for its color/onChange and orientation for its vertical.
Examples
Default
export const Default: Story = {};Saturation
export const Saturation: Story = {
args: { channel: 'saturation', defaultValue: { h: 208, s: 0.6, v: 0.8 } },
};Brightness
export const Brightness: Story = {
args: { channel: 'value' },
};Vertical
export const Vertical: Story = {
args: { orientation: 'vertical' },
};Right To Left
export const RightToLeft: Story = {
render: (args) => (
<div dir="rtl" className="w-64">
<ColorSlider {...args} />
</div>
),
};Props
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
channel | 'hue' | 'saturation' | 'value' | No | 'hue' | The channel the slider edits. |
orientation | 'horizontal' | 'vertical' | No | 'horizontal' |
|
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, the pointer or assistive technology) that changes it (Fluent's | |
shape | 'square' | 'rounded' | No | 'rounded' |
|
labels | ColorSliderLabels | No | Texts of the slider; bound to a ColorPicker, the picker's | |
disabled | boolean | No | false | Unavailable: the input is natively disabled and the slider dimmed. A bound slider 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 slider 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 | |
ref | React.Ref<HTMLInputElement> | No | Ref to the | |
slotProps | { root?: SlotPart<'div'>; rail?: SlotPart<'div'>; thumb?: SlotPart<'span'> } | No | Props for the elements the slider draws, by part, merged into each part's own (Fluent UI's |
Any other prop is passed to the element it renders (HTMLDivElement).
Parts
rootrailthumb
Stable class names
| Part | Class |
|---|---|
root | wave-color-slider |
rail | wave-color-slider__rail |
thumb | wave-color-slider__thumb |