enes

Slider

A slider lets users select a value from a continuous or discrete range by dragging a thumb along a track. It supports horizontal and vertical orientations, tick marks, a value tooltip and reverse direction.

Usage

<script>
	import { Slider } from 'fluentui-svelte';
</script>

<Slider value={50} min={0} max={100} />

Range and Step

Use the min, max and step props to control the range of values and the increment between them.

Ticks

Provide an array of values to the ticks prop to render tick marks along the track. Use tickPlacement to position them around, before or after the rail.

Vertical Orientation

Set orientation to vertical to lay the slider out vertically. Make sure the container has a defined height so the slider is visible.

Disabled

Set the disabled prop to prevent interaction with the slider.

Component Props

NameTypeDefaultDescription
value bindablenumber0The current value of the slider.
minnumber0The minimum value of the slider.
maxnumber100The maximum value of the slider.
stepnumber1How much the value moves on every step.
ticksnumber[][]The values the tick marks are drawn at.
tickPlacement'around' | 'before' | 'after''around'Where the tick marks sit relative to the rail.
prefixstring''Text prepended to the value in the tooltip.
suffixstring''Text appended to the value in the tooltip.
trackbooleantrueWhether to fill the rail up to the current value.
orientation'horizontal' | 'vertical''horizontal'The direction the slider runs in.
reversebooleanfalseRuns the slider from the maximum to the minimum instead.
disabledbooleanfalseDisables the user interaction.
syncbooleanSnaps the thumb to the pointer as soon as it is pressed, instead of stepping towards it.
tooltipbooleantrueWhether to show the value in a tooltip while dragging.
tooltipPlacementPlacement'top'Where the tooltip is placed relative to the thumb.
tooltipContentstring | Snippet | ComponentCustom content for the tooltip, replacing the plain value.
onChange(value: number) => voidCalled whenever the value changes.
classstringThe class to apply to the slider.
ref bindableHTMLElementThe DOM reference of the slider element.
inputRef bindableHTMLInputElementThe DOM reference of the underlying input element.
thumbRef bindableHTMLElementThe DOM reference of the thumb element.
tooltipRef bindableHTMLElementThe DOM reference of the tooltip element.
railRef bindableHTMLElementThe DOM reference of the rail element.
trackRef bindableHTMLElementThe DOM reference of the track element.
tickBarRef bindableHTMLElementThe DOM reference of the tick bar element.
Element Attributes (div)