change
Description
fires when the state of a checkbox is changedParameters
- ev - (object) a CustomEvent object. Its
detail
property contains:- value - (boolean) the state of a checkbox
- name - (string) the name of a checkbox
Example
<script>
function handleChange(ev) {
const newState = ev.detail;
console.log(newState);
// => {value: true, name: 'Option 1'}
}
</script>
<Checkbox label="Checkbox" name="Option 1" on:change={handleChange}/>
Details
The handler function receives an object with the value of a checkbox and its name.
Related article: Catching the change of a checkbox state