Radio Group
A set of checkable buttons, known as radio buttons, where no more than one of the buttons can be checked at a time.
Preview
Installation
npx sigma-ui@latest add radio-groupUsage
<script setup lang="ts">
import { Label } from '@/components/ui/label';
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group';
</script>
<template>
<RadioGroup default-value="option-one">
<div class="flex items-center space-x-2">
<RadioGroupItem
id="option-one"
value="option-one"
/>
<Label for="option-one">Option One</Label>
</div>
<div class="flex items-center space-x-2">
<RadioGroupItem
id="option-two"
value="option-two"
/>
<Label for="option-two">Option Two</Label>
</div>
</RadioGroup>
</template>- Use
defaultValueto check an item initially, orv-modelto control the checked item. - Set
orientationto match the layout, so the arrow keys move in the expected direction.
Examples
Form
Read the vee-validate docs to learn more about form validation.
API Reference
RadioGroup
Props
| Prop | Type | Default |
|---|---|---|
modelValueThe controlled value of the radio item to check. Can be binded as | AcceptableValue | - |
defaultValueThe value of the radio item that should be checked when initially rendered. Use when you do not need to control the state of the radio items. | AcceptableValue | - |
disabledWhen | boolean | - |
orientationThe orientation of the component. | DataOrientation | - |
dirThe reading direction of the combobox when applicable. <br> If omitted, inherits globally from | Direction | - |
loopWhen | boolean | - |
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
nameThe name of the field. Submitted with its owning form as part of a name/value pair. | string | - |
requiredWhen | boolean | - |
Events
| Event | Payload |
|---|---|
update:modelValueEvent handler called when the radio group value changes | [payload: AcceptableValue] |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
RadioGroupItem
Props
| Prop | Type | Default |
|---|---|---|
disabledWhen | boolean | - |
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
valueThe value given as data when submitted with a | AcceptableValue | - |
nameThe name of the field. Submitted with its owning form as part of a name/value pair. | string | - |
requiredWhen | boolean | - |
id | string | - |
Accessibility
Adheres to the Radio Group WAI-ARIA design pattern and uses roving tabindex to manage focus between the items. Reka UI handles it.
| Key | Description |
|---|---|
| Tab | Moves focus to the checked item, or to the first item in the group. |
| Space | When focus is on an unchecked item, checks it. |
| ArrowDown | Moves focus to the next item and checks it. |
| ArrowRight | Moves focus to the next item and checks it. |
| ArrowUp | Moves focus to the previous item and checks it. |
| ArrowLeft | Moves focus to the previous item and checks it. |