1
0
Fork 1
mirror of https://github.com/elk-zone/elk.git synced 2024-11-20 07:49:57 +00:00
elk/components/common/CommonCheckbox.vue
2023-05-20 21:23:41 +02:00

40 lines
915 B
Vue

<script setup lang="ts">
defineProps<{
label?: string
hover?: boolean
iconChecked?: string
iconUnchecked?: string
}>()
const { modelValue } = defineModels<{
modelValue?: boolean | null
}>()
</script>
<template>
<label
class="common-checkbox flex items-center cursor-pointer py-1 text-md w-full gap-y-1"
:class="hover ? 'hover:bg-active ms--2 px-4 py-2' : null"
v-bind="$attrs"
@click.prevent="modelValue = !modelValue"
>
<span v-if="label" flex-1 ms-2 pointer-events-none>{{ label }}</span>
<span
:class="modelValue ? (iconChecked ?? 'i-ri:checkbox-line') : (iconUnchecked ?? 'i-ri:checkbox-blank-line')"
text-lg
aria-hidden="true"
/>
<input
v-model="modelValue"
type="checkbox"
sr-only
>
</label>
</template>
<style>
.common-checkbox:focus-within {
outline: none;
border-bottom: 1px solid var(--c-text-base);
}
</style>