Options (Props)
Below you’ll find a list of options (props) that you can pass to the component to configure it to your liking. There’s a link to an example for each option.
value
Number
50
A default value to apply to the Slider.
A Slider with range
property must use values
instead
values
Array
[50]
Array of values to apply on the Slider. If multiple values are provided, multiple handles will be rendered.
A Slider with range
property set can only have two values max
min
Number
0
Minimum value for the Slider
should be set to lower than max
property
max
Number
100
Maximum value for the Slider
should be set to higher than min
property
step
Number
1
Every nth
value to allow handle to stop at. For example if the step
is 5
, then the handle will only stop at 5
, 10
, 15
, 20
, etc.
should be a positive value
pips
Boolean
false
Whether to show pips/notches on the Slider. The pips will be rendered at the pipstep
value. Pips can be styled as necessary but by default sit below the Slider (Horizontal) like a gauge.
pipstep
Number
1
Every nth
step to show a pip for. This has multiple defaults depending on min
, max
and step
properties. A sensible default is chosen, but can be overridden.
should be a positive value
range
Boolean | String
false
Whether to style as a range picker. Possible values are:
false
no range stylingtrue
styles like a range with amin
andmax
min
styles like a range going frommin
tovalue
max
styles like a range going fromvalue
tomax
A Slider with range=min/max
or range=true
only have one or two values respectively.
pushy
Boolean
false
If range
is true
, then this decides if one handle will push the other along. By default, the handles will not push each other along, they will block each other.
float
Boolean
false
Set true to add a floating label above focussed handles. This is good for displaying the current value of the Slider while interacting with it.
vertical
Boolean
false
Make the Slider render vertically (lower value on bottom)
first
Boolean | String
false
Whether to show a pip or label for the first value on Slider. Possible values are:
false
the first value in the Slider will not have a pip or labelpip
a pip (only) will be shown for the first valuelabel
label (and pip) is shown on the first value
last
Boolean | String
false
Whether to show a pip or label for the last value on Slider. Possible values are:
false
the last value in the Slider will not have a pip or labelpip
a pip (only) will be shown for the last valuelabel
label (and pip) is shown on the last value
rest
Boolean | String
false
Whether to show a pip or label for all values except first & last. Possible values are:
false
the middle values in the Slider will not have a pip or labelpip
a pip (only) will be shown for the middle valueslabel
label (and pip) is shown on the middle values
all
Boolean | String
false
Whether to show a pip or label for every value. Possible values are:
false
all values in the Slider will not have a pip or labelpip
a pip (only) will be shown for all valueslabel
label (and pip) is shown on all values
The same as combining first
, last
and rest
.
prefix
String
''
A simple string to prepend to all displayed values
For more complex prefixes, use the formatter
property
suffix
String
''
A simple string to append to all displayed values
For more complex suffixes, use the formatter
property
reversed
Boolean
false
Reverse the orientation of min/max
hoverable
Boolean
true
Whether hover styles are enabled for both handles and pips/values
disabled
Boolean
false
Determine if the Slider is disabled, or enabled
id
String
''
Give the Slider a unique ID for use in styling
ariaLabels
Array
[]
An array of strings to use for the aria-label
attribute on the handles.
The array should be the same length as the values
array.
formatter
Function
(v,i,p) => v
A function to format the value of the Slider. Should return a String value.
function arguments are: v(value), i(handle index), p(percent)
handleFormatter
Function
formatter()
A function to re-format values on the handle/float before they are displayed. Defaults to the same function given to the formatter
property.
function arguments are: v(value), i(handle index), p(percent)
springValues
Object
{ stiffness: 0.15, damping: 0.4 }
Svelte spring physics object to change the behaviour of the handle when moving.
Set to both to 1 for basically no spring effect
slider
Element
undefined
DOM reference for binding to the main <div />
of the component.
e.g. bind:slider={ref}
Useful for doing any kind of manipulation at mount time