onChange
Description
Fires when the state of a checkbox is changedUsage
onChange?: (ev: { value: boolean; inputValue: string | number }) => void;
Parameters
The callback of the event takes an object with the following parameters:
- value - (required) the state of a checkbox
- inputValue - (required) input value associated with the checkbox
Example
function handleChange({ value }: { value: boolean; inputValue?: string | number }) {
console.log(value);
}
<Checkbox label="Checkbox" onChange={handleChange} />
Details
The handler function receives an object with the state of the selected checkbox and its value.
Related article: Catching the change of a checkbox state