onchange
Description
Fires when a new value is selected in a SliderUsage
onchange?: (ev: {
value: number;
previous?: number;
input?: boolean;
}) => void;
Parameters
value
- (required) the newly selected valueprevious
- (optional) the previously selected valueinput
- (optional) true, if the Slider handle is being dragged (check details)
Example
<script>
function handleChange(ev){
const newValue = ev.value;
console.log(newValue);
// => {value: 64}
}
</script>
<Slider onchange={handleChange}/>
Details
The handler function receives an object with the value selected in the slider. The received object may also contain the following:
- if the Slider handle is being dragged, the
change
event of the Slider control will have the previously selected Slider value andinput:true
:
{value: 56, previous: 50, input: true}
- if a new Slider value has been applied, the
change
event of the Slider control will have just thevalue
parameter
Related article: Catching the change of the value
Related sample: Slider