initial commit
This commit is contained in:
19
components/vlToggle.vue
Normal file
19
components/vlToggle.vue
Normal file
@@ -0,0 +1,19 @@
|
||||
<script setup>
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
const checked = ref(false);
|
||||
|
||||
watch(checked, (newValue) => {
|
||||
emit('update:modelValue', newValue);
|
||||
});
|
||||
emit('update:modelValue', checked.value);
|
||||
|
||||
function toggleChecked() {
|
||||
checked.value = !checked.value;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<button class="vl-toggle-button" @click="toggleChecked()" :aria-pressed="checked" :data-state="(checked) ? 'on' : 'off'">
|
||||
<slot />
|
||||
</button>
|
||||
</template>
|
||||
Reference in New Issue
Block a user