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.
rangeGapMin
Number
0
New
Sets the minimum allowed distance between handles in a range slider. When pushy
is true, moving a handle past this limit will push the other handle.
Only works when range
is true
rangeGapMax
Number
null
New
Sets the maximum allowed distance between handles in a range slider. When pushy
is true, moving a handle past this limit will pull the other handle.
Only works when range
is true
draggy
Boolean
false
New
Enables dragging of the range area between handles.
Setting the rangeGapMin
and rangeGapMax
to the same value (with draggy
& pushy
on) would simulate a fixed range.
Only works when range
is true
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.
rangeFloat
Boolean
false
New
When true, shows the range values between the handles (e.g., “20 - 80”). Respects existing prefix
and suffix
properties.
Only works when range
is true
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
.
limits
Null | Array
null
An array of values to limit the Slider handles to.
This should be two values (min/max) to limit the handles to
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
class
String
''
New
Add custom CSS classes to the slider element. Useful for custom styling or framework integration.
style
String
''
New
Pass CSS variables or styling directly to the slider.
Works alongside the existing class
prop
darkmode
Boolean | String
false
New
Control the dark mode of the slider. Possible values are:
false
light mode (default)'force'
dark mode'auto'
system preference
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)
All formatters use @html
to render so be careful with what you return
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)
All formatters use @html
to render so be careful with what you return
rangeFormatter
Function
(v1,v2) => `${v1} - ${v2}`
New
A function to format the range float display. Takes two values and returns a string.
Only works when range
is true and rangeFloat
is true
All formatters use @html
to render so be careful with what you return
spring
Boolean
true
New
Controls handle animations. When false, disables all animations on the slider handles for instant updates.
springValues
Object
{ stiffness: 0.15, damping: 0.4 }
Svelte spring physics object to change the behaviour of the handle when moving.
precision
Number
2
New
The number of decimal places to display for the Slider values.
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