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.

Buffer

Set buffer to draw a second value on the rail, behind the track, such as how much of a media has loaded. It takes the scale of value and does not move the thumb.

Disabled

Set the disabled prop to prevent interaction with the slider.

Form Control Attributes

The root is the control element. HTML attributes, class and ref apply to that element. There is no separate wrapper API.

Component Props

NameTypeDefaultDescription
value bindablenumber0The current value of the slider.
defaultValuenumberminThe value a form reset returns the slider to. A range input without one would fall back to an empty value.
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.
buffernumberA second value drawn on the rail behind the track, such as how much of a media has loaded. It takes the scale of value and does not move the thumb.
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. Without it, a value between two steps is drawn as it is, while the native input, and so the form, holds the nearest step.
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.
tooltipPositionConfigPartial<ComputePositionConfig>The position configuration handed over to floating-ui for the tooltip, as in Tooltip.
onChange(value: number) => voidCalled whenever the value changes.
ref bindableHTMLInputElement | nullThe DOM reference of the native range input that holds the value and takes the keyboard focus. The other attributes of the slider are applied to it.
wrapperRef bindableHTMLDivElement | nullThe DOM reference of the element that draws the slider.
wrapperAttributesHTMLAttributesThe attributes to spread on the element that draws the slider.
thumbRef bindableHTMLElement | nullThe DOM reference of the thumb element.
tooltipRef bindableHTMLElement | nullThe DOM reference of the tooltip element.
railRef bindableHTMLElement | nullThe DOM reference of the rail element.
trackRef bindableHTMLElement | nullThe DOM reference of the track element.
tickBarRef bindableHTMLElement | nullThe DOM reference of the tick bar element.
HiddenInputAttributes<HTMLInputAttributes>
Edit this Doc View as Markdown