Skip to main content

onchange

Description

Fires when the state of the Two State button changes

Usage

onchange?: (ev: { value: boolean }) => void;

Parameters

The callback of the event takes an object with the following parameter:

  • value - (required) defines if the button is pressed ("true") or unpressed ("false")

Example

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

<template>
<TwoState :onchange="handleChange"/>
</template>

Details

The handler function receives an object with the button state which can be "true" or "false".

Related article: Catching the change of selected options