Skip to content

GkRadioGroup & GkRadio

GkRadioGroup provides a shared name and v-model for GkRadio children, with optional group disabled / readonly (aligned with GkCheckbox / GkInput patterns). Use ariaLabel on the group when there is no visible group heading.

When to use

Use radios when users must choose exactly one option from a small, mutually exclusive set.

Live demo

API

GkRadioGroup props

PropTypeDefaultDescription
modelValuestring | number | undefinedSelected value (v-model)
namestringOptional; defaults to a stable generated name
ariaLabelstringAccessible name for the radiogroup
disabledbooleanfalseDisables all radios (each radio can still set disabled)
readonlybooleanfalsePrevents changing the selection; aria-readonly on the group

Root class applies to the group container; other attributes are forwarded to the radiogroup wrapper.

GkRadio props

PropTypeDefaultDescription
valuestring | numberrequiredValue when this option is selected
disabledbooleanfalseDisables this option (combined with group disabled)

Events (GkRadioGroup)

EventPayloadDescription
update:modelValuestring | number | undefinedNew selection

Events (GkRadio)

EventPayloadDescription
update:focusedbooleanFocus on the native radio

Expose (GkRadio)

NameTypeDescription
inputHTMLInputElementNative radio

GK_RADIO_GROUP

Injected context includes isDisabled and isReadonly for the group. See Composables and GkRadioGroupContext in the package types.

Examples

Basic

vue
<script setup lang="ts">
import { GkRadio, GkRadioGroup } from 'god-kit/vue'
import { ref } from 'vue'
const theme = ref<'light' | 'dark'>('light')
</script>

<template>
  <GkRadioGroup v-model="theme" aria-label="Theme">
    <GkRadio value="light">Light</GkRadio>
    <GkRadio value="dark">Dark</GkRadio>
  </GkRadioGroup>
</template>

Advanced

vue
<GkRadioGroup v-model="theme" aria-label="Theme" :disabled="saving">
  <GkRadio value="light">Light</GkRadio>
  <GkRadio value="dark">Dark</GkRadio>
</GkRadioGroup>

Edge case

vue
<GkRadioGroup v-model="theme" readonly aria-label="Theme readonly review">
  <GkRadio value="light">Light</GkRadio>
  <GkRadio value="dark">Dark</GkRadio>
</GkRadioGroup>

Accessibility notes

  • Provide a group-level label (ariaLabel or visible heading) so assistive tech can announce context.
  • Use radios only when one and only one option can be selected.

Released under the MIT License.