AlphaSlider
A slider for a color's opacity, drawn over a checkerboard, horizontal (mirrored in right-to-left layouts) or vertical (bottom to top); transparency shows transparency instead. The arrow keys move by 1 %, 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 "Opacity" ("Transparency"). 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 AlphaSlider, with value/onValueChange for its color/onChange.
Examples
Default
export const Default: Story = {};Transparency
export const Transparency: Story = {
args: { transparency: true },
};Vertical
export const Vertical: Story = {
args: { orientation: 'vertical' },
};Props
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
transparency | boolean | No | false | Shows transparency (100 % is fully transparent) instead of opacity: the rail, the input's value, the value text and the arrow direction all follow it, while |
labels | AlphaSliderLabels | No | Texts of the slider; bound to a ColorPicker, the picker's | |
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 | |
form | string | No | Id of the form the slider belongs to, when it is rendered outside that form. | |
ref | React.Ref<HTMLInputElement> | No | Ref to the | |
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 ( | |
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). |
shape | 'square' | 'rounded' | No | 'rounded' |
|
orientation | 'horizontal' | 'vertical' | No | 'horizontal' |
|
required | boolean | No | Marks the hidden form input required (a color is always set, so it never blocks). A consumer | |
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 |
Any other prop is passed to the element it renders (HTMLDivElement).
Parts
rootrailthumb
Stable class names
| Part | Class |
|---|---|
root | wave-alpha-slider |
rail | wave-alpha-slider__rail |
thumb | wave-alpha-slider__thumb |