Skip to content

FormRadio

Radio button + group built on Reka UI's RadioGroup primitives. The group owns the v-model (single value); each item declares a value prop and renders a Reka RadioGroupItem + RadioGroupIndicator. Roving focus across siblings comes for free.

bash
npm install @vuecs/forms

Basic usage

vue
<script setup lang="ts">
import { VCFormRadio, VCFormRadioGroup } from '@vuecs/forms';
import { ref } from 'vue';

const size = ref<string>('md');
</script>

<template>
    <VCFormRadioGroup v-model="size">
        <VCFormRadio value="sm" label-content="Small" />
        <VCFormRadio value="md" label-content="Medium" />
        <VCFormRadio value="lg" label-content="Large" />
    </VCFormRadioGroup>
</template>
css
@import "tailwindcss";
@import "@vuecs/design";

@import "@vuecs/forms";

@custom-variant dark (&:where(.dark, .dark *));

Options shorthand

For declarative use, pass :options="FormOption[]" to the group instead of compound children. The group renders one <VCFormRadio> per option automatically:

vue
<VCFormRadioGroup
    v-model="size"
    :options="[
        { value: 'sm', label: 'Small' },
        { value: 'md', label: 'Medium' },
        { value: 'lg', label: 'Large' },
    ]"
/>

Props (<VCFormRadio>)

PropTypeDefaultDescription
valueAcceptableValue(required)Bound value when this item is selected
disabledbooleanfalseDisable interaction; reflected as data-disabled
idstring(auto)Override the auto-generated id
labelbooleantrueRender the label wrapper
labelContentstring(defaults system)Inline label text
themeClassPartial<FormRadioThemeClasses>undefinedPer-instance theme override
themeVariantRecord<string, string | boolean>undefinedPer-instance variant values

Props (<VCFormRadioGroup>)

PropTypeDefaultDescription
modelValueAcceptableValueundefinedCurrently selected value
optionsFormOption[]undefinedOptional declarative shorthand for compound children
orientation'vertical' | 'horizontal''vertical'Layout + arrow-key direction
loopbooleantrueWrap arrow-key focus from last to first
disabledbooleanfalseDisable every item
requiredbooleanfalseForm-required attribute
namestringundefinedForm-submission name

Events

EventPayloadDescription
update:modelValueAcceptableValueEmitted on selection change

Released under the Apache 2.0 License.