Slider
A native range input with Fluent styling: a rail drawn in the accessible stroke color (3:1 against the page), filled in the primary color up to a primary thumb; in forced-colors mode the rail, fill and thumb are drawn in system colors. Inside a Field it picks up the label, hint, validation message, required and invalid state automatically.
The fill follows the value through the --wave-slider-progress variable on the input (also in the server HTML), including the browser's snapping to step and a form reset.
size (small, medium) sets the thumb and rail dimensions; the input carries data-size. orientation="vertical" runs the rail up (see its docs); the input carries data-orientation. Slider does not read a surrounding Field's size or a WaveProvider's input defaults.
Examples
Default
export const Default: Story = {};Min Max
export const MinMax: Story = {
args: {
label: 'Temperature',
min: 0,
max: 100,
defaultValue: 25,
},
};With Step
export const WithStep: Story = {
args: {
label: 'Quantity',
min: 0,
max: 50,
step: 5,
defaultValue: 10,
},
};Disabled
export const Disabled: Story = {
args: {
label: 'Brightness',
disabled: true,
},
};Sizes
export const Sizes: Story = {
render: (args) => (
<div className="grid gap-4">
<Slider {...args} size="small" defaultValue={30} aria-label="Small volume" />
<Slider {...args} size="medium" defaultValue={60} aria-label="Medium volume" />
</div>
),
};Right To Left
export const RightToLeft: Story = {
args: {
defaultValue: 30,
},
render: (args) => (
<div dir="rtl" className="w-64">
<Slider {...args} />
</div>
),
};Vertical
export const Vertical: Story = {
render: (args) => (
<div className="flex items-end gap-8">
<Slider {...args} orientation="vertical" size="small" aria-label="Small volume" />
<Slider {...args} orientation="vertical" aria-label="Medium volume" />
<Slider {...args} orientation="vertical" className="h-48" aria-label="Tall volume" />
<Slider {...args} orientation="vertical" disabled aria-label="Disabled volume" />
</div>
),
};Props
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
value | number | No | Controlled slider value. | |
defaultValue | number | No | Initial value for uncontrolled usage. | |
onChange | React.ChangeEventHandler<HTMLInputElement> | No | Native change event handler ( | |
onValueChange | (value: number) => void | No | Called with the new value as a number on every change, next to the native | |
min | number | No | Minimum allowed value. | |
max | number | No | Maximum allowed value. | |
step | number | No | Step increment between values. | |
label | string | No | Accessible label for the slider (sets | |
size | 'small' | 'medium' | No | 'medium' | Size of the thumb and rail: the 0.7 20px thumb on a 4px rail, or a small 16px thumb on a 2px rail in a 24px-tall input. Unlike the text controls and pickers, Slider does not read a surrounding |
orientation | 'horizontal' | 'vertical' | No | 'horizontal' | Direction of the rail (Fluent UI's |
ref | React.Ref<HTMLInputElement> | No | Ref to the |
Any other prop is passed to the element it renders (HTMLInputElement).
Stable class names
| Part | Class |
|---|---|
root | wave-slider |