Skip to content
Slider - Web Component โ
The Slider component can be used imported from:
Playground โ
Parameters โ
The Web component uses the <z-slider>
tag:
By default, all the parameters are optional or can be set in different, except for the ones marked as required
The parametrization of the component can be done with the following custom HTML params:
Name | Type | Description | Slot | A11y |
---|---|---|---|---|
label | string | The label of the slider | ||
disabled | boolean | Blocks the interaction with the input component. | ||
required | boolean | Marks the input component as required. | ||
name | string | Identification for the field inside the form | ||
help-text | string | The forced message to be shown under the input | help-text | |
invalid | boolean | Whether the input is invalid | ||
range | number[] | The range of the slider | ||
icon-right | string | The icon to show on the right side of the slider | ||
icon-left | string | The icon to show on the left side of the slider | ||
show-max | boolean | Whether to show the maximum value of the slider | ||
show-min | boolean | Whether to show the minimum value of the slider |
Events โ
This component has events. Check the documentation about how to use the events.
Name | Payload | Description |
---|---|---|
change | number | Returns the new value of the "value" attribute |
restarted | void | Emitted on value reset |
Slots โ
This component has slots. Check the documentation about how to use the slots.
Name | Tags | Description |
---|
Parameters use โ
label
โ
The label
parameter is used to set the label of the slider.
model
โ
The value
parameter is used to set the value of the slider. Make sure the value is within the range.
name
โ
The name
parameter is used to set the name of the slider. This name will be used when submitting the form.
range
โ
The range
parameter is used to set the range of the slider. The range must be an array with two values, the first value is the minimum value, and the second value is the maximum value.
If no value is provided it uses [0, 100]
.
min
โ
Instead of using range
we can use just min
. This overrides the range
value.
max
โ
Instead of using range
we can use just max
. This overrides the range
value.
icon-right
โ
The icon-right
parameter is used to set an icon on the right side of the slider. Use the icon name from the Icon component.
icon-left
โ
Same as icon-right
, but the icon will be on the left side of the slider.
Flags โ
disabled
โ
The disabled
parameter is used to block the interaction with the slider, and it will not be possible to change the value.
required
โ
The required
parameter is used to make the slider required.
invalid
โ
We can set the invalid
attribute as for any other WebComponent input:
This affects the style of the entire input:
show-max
โ
The show-max
parameter is used to show the maximum value of the slider.
show-min
โ
The show-min
parameter is used to show the minimum value of the slider.
Methods โ
reset()
โ
We can all the reset()
method of the WebComponent in order to reset the value. This will clean the internal states and emit the nullable value with the change
event, plus a restarted
event:
In this example, the button triggers the method:
Value:ย
50
The reset is done to 0
.
Browser support โ
Detected engine: ย
Chromium
Webkit
Gecko