RadioGroup.vue 572 B

1234567891011121314151617181920212223242526
  1. <template>
  2. <div class="flex flex-col">
  3. <SmartRadio
  4. v-for="(radio, index) in radios"
  5. :key="`radio-${index}`"
  6. :value="radio.value"
  7. :label="radio.label"
  8. :selected="value === radio.value"
  9. @change="emit('input', radio.value)"
  10. />
  11. </div>
  12. </template>
  13. <script setup lang="ts">
  14. const emit = defineEmits<{
  15. (e: "input", value: string): void
  16. }>()
  17. defineProps<{
  18. radios: Array<{
  19. value: string // The key of the radio option
  20. label: string
  21. }>
  22. value: string // Should be a radio key given in the radios array
  23. }>()
  24. </script>