onChange
Description
Fires when a new segment is selected in the segmented buttonUsage
onChange?: (ev: { value: string | number }) => void;
Parameters
The callback of the event takes the ev
object with the following parameter:
- value - (string | number) an id of the newly selected segment or "" if the value is cleared
Example
function App() {
function handleChange(ev: { value: string | number }) {
console.log(ev.value);
// => id of selected option
}
return <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