Slider
KSlider is a draggable horizontal input for selecting a numeric value within a range.
<KSlider
v-model="nodesCount"
label="Select a random number in the range from 1 to 10"
:min="1"
/>
2
3
4
5
NOTE
KSlider is best used in scenarios such as specifying volume or rating satisfaction - where the ranges are generally small and the exact selected value is not important. For scenarios requiring precise input in a large range, use KInput type="number" instead.
Props
v-model
KSlider works with v-model
for two-way data binding.
<template>
<KSlider
v-model="nodesCount"
label="Select a random number in the range from 1 to 10"
:min="1"
/>
</template>
<script setup lang="ts">
const nodesCount = ref<number>(5)
</script>
2
3
4
5
6
7
8
9
10
11
label
String to be used as label. Default value is empty string (''
).
<KSlider
label="In the binary system, which value is used to represent true?"
v-model="binaryTrue"
:max="1"
/>
2
3
4
5
min
Minimum value of the range (number). Default value is 0
.
max
Minimum value of the range (number). Default value is 10
.
step
Step value (number). Default value is 1
.
<KSlider
v-model="sliderValue"
:max="100"
:min="40"
:step="5"
show-marks
/>
2
3
4
5
6
7
showMarks
Boolean value to control whether or not marks for every step on the range should be shown. Marks for minimum and maximum values are shown at all times.
Defaults to false
.
<KSlider
show-marks
v-model="sliderValue"
:max="50"
:step="5"
/>
2
3
4
5
6
marks
The marks
prop is useful for displaying custom labels or marks at specific values. It accepts an array of numbers or an array of objects with label
and value
properties: { label: string, value: number }
.
NOTE
If showMarks
prop is true
, the values provided through this prop take precedence over default marks generated by KSlider.
<KSlider
:marks="[1, 3, 5, 7, 10]"
v-model="vModel6"
label="Approximate number of API requests (monthly in millions)"
:max="10"
:min="1"
/>
2
3
4
5
6
7
<KSlider
:marks="[
{
label: 'Very unlikely',
value: 0,
},
{
label: 'Neither likely nor unlikely',
value: 5,
},
{
label: 'Very likely',
value: 10,
},
]"
v-model="userRating"
label="How likely are you to recommend Kongponents to a friend or colleague?"
:show-value="false"
/>
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
WARNING
KSlider does not handle collisions between neighboring marks content. Make sure to allocate enough horizontal room to display your custom text.
showValue
Boolean that controls whether KSlider should display a popover showing the input value on interaction. Defaults to true
.
<KSlider
:show-value="false"
v-model="vModel8"
/>
2
3
4
disabled
Boolean to control whether or not the input should be disabled.
<KSlider
disabled
v-model="sliderValue"
/>
2
3
4
labelAttributes
Use the labelAttributes
prop to configure the KLabel's props when using the label
prop.
Events
update:modelValue
Fired on change, returns the new value of the slider.
change
Fired on change, returns the new value of the slider.