Slider
Slider is a form element with which users can set a value by dragging a cursor along a bar. It uses a knob or lever moved horizontally to control a variable, such as volume on a radio or brightness on a screen.
Continuous slider
Continuous slider allow users to select a value along a subjective range.
The default slider has a minimum value of 0, a maximum value of 100, and a step value of 1. The handle is positioned at the minimum value.
<QtmSlider></QtmSlider>
<QtmSlider min={0} max={100} step={1} value={0}></QtmSlider>
Sizes
The slider is available in three sizes to cater for the diverse range of use cases and devices that our business uses. By default the slider is medium.
<QtmSlider size="small" value={50}></QtmSlider>
<QtmSlider size="medium" value={50}></QtmSlider>
<QtmSlider size="large" value={50}></QtmSlider>
Colors
By default, the sliders is emphasized (primary theme). Providing a visual prominence. For visual components where you don’t want to emphasize the slider component, the neutral theme is more appropriate for this deprioritization its focus on the screen.
<QtmSlider color="primary" value={50}></QtmSlider>
<QtmSlider color="neutral" value={50}></QtmSlider>
Disabled
<QtmSlider color="primary" disabled value={50}></QtmSlider>
<QtmSlider color="neutral" disabled value={50}></QtmSlider>
Label, Caption and Metric
The slider can have a label a caption and a metric label respectively with attributes label caption and has-metric
<QtmSlider label="Label" caption="Caption" value={50} hasMetric></QtmSlider>
Discrete slider
Discrete slider can be adjusted to a specific value by referencing its value indicator. You can generate a mark for each step with marks=.
<QtmSlider marks hasMetric value={50} step={10} />
Small steps
You can change the default step increment.
<QtmSlider
marks
step={0.00000001}
min={-0.00000005}
max={0.0000001}
hasMetric
></QtmSlider>
Custom marks
You can restrict the marks to those provided with the marks prop.
A mark object passed through the marks prop must have a value. It can be visible or invisible. It can be main one or secondary one. And it can be with or without a legend label.
const marks = [
{
value:0,
label:"0°C",
main: true,
visible: true
},
{
value:10,
label:"10°C",
},
{
value:50,
label:"50°C",
main: true,
},
{
value: 90,
label:"90°C",
},
{
value:100,
label:"100°C",
main: true,
},
]
<QtmSlider marks={marks} hasMetric value={50}></QtmSlider>
Restricted values
You can restrict the selectable values to those provided with the marks prop with step={null}.
const marks = [
{
value:0,
label:"0°C",
},
{
value:10,
label:"10°C",
},
{
value:50,
label:"50°C",
},
{
value: 90,
label:"90°C",
},
{
value:100,
label:"100°C",
},
]
<QtmSlider marks={marks} step={null} hasMetric value={50}></QtmSlider>
Legend Position
You can put the mark labels on top or bottom with the legendPosition property.
<QtmSlider marks={marks} hasMetric value={50} legendPosition="top"></QtmSlider>
Two Handles
The slider can be used to set the start and end of a slider range by supplying an array of values to the value prop.
<QtmSlider value={[10, 50]} hasMetric></QtmSlider>
With marks
<QtmSlider value={[10, 50]} hasMetric marks step={10}></QtmSlider>