QSlider 🎚️
The Slider is used to allow users to make selections from a range of values. Try story
Example
Default case:
Props
modelValue
- Type:
String
|Number
|Boolean
, - Default:
null
The binding value.
Template:
<template>
<q-slider
v-model="value"
:data="data"
/>
</template>
1
2
3
4
5
6
2
3
4
5
6
Component instance:
export default {
setup() {
const value = ref('normal');
const data = [
{
value: 'easy',
label: 'Easy'
},
{
value: 'normal',
label: 'Normal'
},
{
value: 'hard',
label: 'Hard'
}
];
return { data, value };
}
});
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
data
- Type:
Array
- Required:
true
Slider data
is an Array
of objects having the following properties:
value
- The value of the sliderlabel?
- The label of the sliderstyle?
- custom styles for caption slot (StyleValue
type from'vue'
)slotData?
- pass custom fields into caption (see example below)
type QSliderData<T> = {
value: T;
label?: string;
style?: StyleValue;
};
// sorry for that
export type QSliderPropData<
T extends ModelValue = ModelValue,
S extends SlotData = undefined
> = (S extends SlotData
? S extends undefined
? QSliderData<T>
: QSliderData<T> & { slotData: S }
: QSliderData<T>)[];
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Template:
<template>
<q-slider
v-model="valueSlot"
:data="dataSlot"
>
<template #caption="{ label, data }">
<div style="margin: 0; font-size: 14px; line-height: 18px">
{{ label }}
</div>
<div style="margin-top: 4px; font-size: 10px; line-height: 12px">
{{ data?.description }}
</div>
</template>
</q-slider>
</template>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Component instance:
export default {
setup() {
const value = 'normal';
const dataSlot = [
{
value: 'easy',
label: 'Easy',
style: {
color: 'blue'
},
slotData: {
description: 'easy description'
}
},
{
value: 'normal',
label: 'Normal',
style: "width: '127px'",
slotData: {
description: 'medium description'
}
},
{
value: 'hard',
label: 'Hard',
style: {
width: '135px'
},
slotData: {
description: 'hard description'
}
}
];
return { dataSlot, value };
}
};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Example:
tooltipMode
- Type:
'hover' | 'always'
, - Default:
null
Slider's tooltip displaying mode: 'hover' | 'always'. If null, the tooltip will be hidden.
Template:
<template>
<q-slider
v-model="value"
:data="data"
tooltip-mode="always"
>
</template>
1
2
3
4
5
6
7
2
3
4
5
6
7
Component instance:
showSteps
- Type:
Boolean
, - Default:
false
Whether Slider steps is visible.
Template:
<template>
<q-slider
v-model="value"
:data="data"
:show-steps="true"
>
</template>
1
2
3
4
5
6
7
2
3
4
5
6
7
Component instance:
Events
update:modelValue
Triggers when model updates.