Skip to content

Radio Group

Choose one option from a group.

Demos

Size
Framework

Usage

vue
<script setup lang="ts">
import { Accordion } from '~/components/ui/accordion'

const items = [
  { value: 'source', label: 'Do I own the source?', content: 'Yes. Copy and adapt the files.' },
]
</script>

<template>
  <Accordion :items="items" />
</template>

Installation

Complete the shared installation. Copy RadioGroup.vue and index.ts into app/components/ui/radio-group/.

API

Variants and defaults

PropValuesDefault
sizexs, sm, md, lg, xlsm

Radio Group uses 8, 10, 12, 14, and 16px spacing for xs through xl. Selection fades and scales the inner dot over 180ms; reduced motion disables the transition.

Props

PropTypeDefaultDescription
optionsany[]—Required. Array of option values or objects.
valueKeystring—Property to use as the value when options are objects.
labelKeystring"label"Property to use as the display label.
descriptionKeystring"description"Property to use as the description text.
disabledbooleanfalseDisable all options.
orientation"horizontal" | "vertical""vertical"Layout direction.
legendstring—Visible group label. Slot #legend takes priority.
loopbooleantrueWrap arrow key navigation at the ends.
namestring—HTML name for form submission.
requiredbooleanfalseMarks the group as required.
ariaLabelstring—aria-label on the group element.
ariaLabelledbystring—aria-labelledby on the group element.
getItemDisabled(option: any) => boolean—Function to disable individual options.
asstring"div"Root element tag.
uiRadioGroupUi—CSS class overrides.

Slots

SlotScoped propsDescription
legend{ legend }Group label. Defaults to the legend prop.
item{ option, value, label, description, isChecked, isDisabled, select }Each radio option.

Events

EventPayloadDescription
value-change[value: string, details]Fired when selected value changes.

Keyboard

KeyBehavior
ArrowUp / ArrowDownSelects and focuses previous/next enabled item in vertical groups.
ArrowLeft / ArrowRightSelects and focuses previous/next enabled item in horizontal groups.
Home / EndSelects and focuses first or last enabled item.
SpaceSelects focused radio.
TabEnters group at selected item, or first enabled item.

Arrow navigation wraps when loop is true and skips disabled items.