checkbox.vue 837 B

123456789101112131415161718192021
  1. <template>
  2. <div class="input checkbox" :style="{ width, height }" :class="{ disabled }">
  3. <input :disabled="disabled" :id="id" type="checkbox" class="replace-input" :checked="props.modelValue" @input="ev => emit('update:modelValue', ev.target.checked)" />
  4. <span class="replace">
  5. <icon :type="props.modelValue ? 'checkbox' : 'nor'" :size="width > height ? height : width" />
  6. </span>
  7. </div>
  8. <label class="label" v-if="props.label" :for="id">
  9. {{ props.label }}
  10. </label>
  11. </template>
  12. <script setup>
  13. import icon from '../icon'
  14. import { checkboxPropsDesc } from './state'
  15. import { randomId } from '../../utils'
  16. import { defineProps, defineEmits } from 'vue'
  17. const props = defineProps(checkboxPropsDesc)
  18. const emit = defineEmits(['update:modelValue'])
  19. const id = randomId(4)
  20. </script>