Skip to content

Instantly share code, notes, and snippets.

@GoodNew5
Created April 13, 2023 22:57
Show Gist options
  • Save GoodNew5/e28fac165e411dd957c203b5f92bc567 to your computer and use it in GitHub Desktop.
Save GoodNew5/e28fac165e411dd957c203b5f92bc567 to your computer and use it in GitHub Desktop.
switch template
<script lang="ts" setup>
export interface Props {
disabled?: boolean
checked: boolean
}
defineProps<Props>()
const emit = defineEmits(['update:checked'])
const onInput = (event: Event) => {
emit('update:checked', (event?.target as HTMLInputElement).checked)
}
</script>
<template>
<label class="switch">
<slot />
<input
:disabled="disabled"
:checked="checked"
type="checkbox"
role="switch"
class="input"
@input="onInput"
/>
</label>
</template>
<style scoped src="./Switch.scss" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment