Skip to main content

onchange

Description

Fires when the state of a checkbox is changed

Usage

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

<script>
function handleChange({value}) {
console.log(value);
}
</script>

<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