Skip to main content

onchange

Description​

Fires when a new segment is selected in the segmented button

Usage​

onchange?: (ev: { value: string | number }) => void;

Parameters​

The callback of the event takes the ev object with the following parameter:

  • value - (string) an id of the newly selected segment or "" if the value is cleared

Example​

<script>
function handleChange({value}) {
console.log(value);
// => id of selected option
}
</script>

<Segmented onchange={handleChange}/>

Details​

The handler function receives an object with an id of the newly selected segment.

Related article: Catching the change of the selected segment