Skip to main content

onchange

Description

Fires when the state of a radio button is checked

Usage

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

Parameters

  • value - (required) the state of the radio button:
    • true - checked
    • false - not checked
  • inputValue - (required) input value associated with the radio button

Example

<script>
function handleChange(ev) {
const newState = ev;
console.log(newState);
// => {value: true, inputValue: 'Option 1'}
}
</script>

<Radio label="Checkbox" inputValue="Option 1" onchange={handleChange}/>

Details

The handler function receives an object with the state of a checkbox and its value.

Related article: Catching the change of a checkbox state