Checkbox.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <div
  3. class="cursor-pointer flex-nowrap transition inline-flex items-center justify-center group hover:text-secondaryDark"
  4. @click="$emit('change')"
  5. >
  6. <input
  7. id="checkbox"
  8. type="checkbox"
  9. name="checkbox"
  10. :checked="on"
  11. @change="$emit('change')"
  12. />
  13. <label
  14. for="checkbox"
  15. class="cursor-pointer font-semibold pl-0 align-middle"
  16. >
  17. <slot></slot>
  18. </label>
  19. </div>
  20. </template>
  21. <script>
  22. import { defineComponent } from "@nuxtjs/composition-api"
  23. export default defineComponent({
  24. props: {
  25. on: {
  26. type: Boolean,
  27. default: false,
  28. },
  29. },
  30. })
  31. </script>
  32. <style scoped lang="scss">
  33. input[type="checkbox"] {
  34. @apply appearance-none;
  35. @apply hidden;
  36. & + label {
  37. @apply inline-flex items-center justify-center;
  38. @apply cursor-pointer;
  39. &::before {
  40. @apply border-divider border-2;
  41. @apply rounded;
  42. @apply group-hover:border-accentDark;
  43. @apply inline-flex;
  44. @apply items-center;
  45. @apply justify-center;
  46. @apply text-transparent;
  47. @apply h-4;
  48. @apply w-4;
  49. @apply font-icon;
  50. @apply mr-3;
  51. @apply transition;
  52. content: "\e876";
  53. }
  54. }
  55. &:checked + label::before {
  56. @apply bg-accent;
  57. @apply border-accent;
  58. @apply text-accentContrast;
  59. }
  60. }
  61. </style>