Create a toggle switch component.

Code Playground
JavaScript (V8)
Loading...
Console Output
// Output will appear here...
// For React: ReactDOM.createRoot(rootElement).render(<App />);
Recommended Answer
<template>
  <button @click="isOn = !isOn">
    {{ isOn ? 'ON' : 'OFF' }}
  </button>
</template>

<script setup>
import { ref } from 'vue';
const isOn = ref(false);
</script>