WlRadioGroup
Appearance
Tab enters the selected or first enabled radio; arrows choose the next enabled option.
Full example
<script setup lang="ts">
const props = { preview: {} as Record<string, unknown> };
import { WlButton, WlRadioGroup } from "legato-ui";
import { computed, ref } from "vue";
const selected = ref<string | undefined>("basic");
const invalid = computed(() => Boolean(props.preview?.invalid ?? !selected.value));
const options = computed(() => [
{ value: "basic", label: "Basic" },
{ value: "team", label: "Team" },
{ value: "enterprise", label: "Enterprise (unavailable)", disabled: true }
]);
</script>
<template>
<div class="wl-stack" data-space="md" data-review-example="WlRadioGroup">
<WlRadioGroup
v-model="selected"
orientation="horizontal"
:options="options"
option-value="value"
option-disabled="disabled"
legend="Plan"
:invalid="invalid"
/>
<p v-if="invalid" role="alert">{{ "Choose a plan." }}</p>
<div class="wl-inline" data-space="sm">
<WlButton size="sm" @click="selected = undefined">{{ "Clear selection" }}</WlButton>
<WlButton size="sm" @click="selected = 'basic'">{{ "Restore example" }}</WlButton>
</div>
<output aria-label="Plan">{{ selected ?? "—" }}</output>
<p class="wl-text-small">{{ "Tab enters the selected or first enabled radio; arrows choose the next enabled option." }}</p>
</div>
</template>States
Tab enters the selected or first enabled radio; arrows choose the next enabled option.
Full example
<script setup lang="ts">
const props = { preview: {} as Record<string, unknown> };
import { WlButton, WlRadioGroup } from "legato-ui";
import { computed, ref } from "vue";
const selected = ref<string | undefined>("basic");
const invalid = computed(() => Boolean(props.preview?.invalid ?? !selected.value));
const options = computed(() => [
{ value: "basic", label: "Basic" },
{ value: "team", label: "Team" },
{ value: "enterprise", label: "Enterprise (unavailable)", disabled: true }
]);
</script>
<template>
<div class="wl-stack" data-space="md" data-review-example="WlRadioGroup">
<WlRadioGroup
v-model="selected"
orientation="horizontal"
:options="options"
option-value="value"
option-disabled="disabled"
legend="Plan"
:invalid="invalid"
/>
<p v-if="invalid" role="alert">{{ "Choose a plan." }}</p>
<div class="wl-inline" data-space="sm">
<WlButton size="sm" @click="selected = undefined">{{ "Clear selection" }}</WlButton>
<WlButton size="sm" @click="selected = 'basic'">{{ "Restore example" }}</WlButton>
</div>
<output aria-label="Plan">{{ selected ?? "—" }}</output>
<p class="wl-text-small">{{ "Tab enters the selected or first enabled radio; arrows choose the next enabled option." }}</p>
</div>
</template>One plan from a labelled group
A labelled radio group with one selected option and shared keyboard navigation.
Choose a plan.
Tab enters the selected or first enabled radio; arrows choose the next enabled option.
Full example
<script setup lang="ts">
import { WlButton, WlRadioGroup } from "legato-ui";
import { computed, ref } from "vue";
const selected = ref<string>();
const options = computed(() => [
{ value: "basic", label: "Basic" },
{ value: "team", label: "Team" },
{ value: "enterprise", label: "Enterprise (unavailable)", disabled: true }
]);
</script>
<template>
<div class="wl-stack" data-space="md" data-review-example="WlRadioGroup">
<WlRadioGroup
v-model="selected"
:options="options"
option-value="value"
option-disabled="disabled"
legend="Plan"
orientation="horizontal"
:invalid="!selected"
/>
<p v-if="!selected" role="alert">{{ "Choose a plan." }}</p>
<div class="wl-inline" data-space="sm">
<WlButton size="sm" @click="selected = undefined">{{ "Clear selection" }}</WlButton>
<WlButton size="sm" @click="selected = 'basic'">{{ "Restore example" }}</WlButton>
</div>
<output aria-label="Plan">{{ selected ?? "—" }}</output>
<p class="wl-text-small">{{ "Tab enters the selected or first enabled radio; arrows choose the next enabled option." }}</p>
</div>
</template>Props
Types, accepted values and literal defaults come from the public manifest. Inherited settings name their source; “Not set” means no default is declared.
v-model: WlOptionValue<
| Prop | Type / values | Default | Purpose |
|---|---|---|---|
options | readonly TOption[] | [] | Readonly options from which the user can select. |
optionLabel | WlOptionLabel< | Not set | Resolve the visible text of an option. |
optionValue | TResolver | Not set | Resolve the value stored in the selection model. |
optionDisabled | WlOptionDisabled< | Not set | Resolve whether an option is disabled. |
optionKey | WlOptionKeyResolver< | Not set | Resolve stable option identity; provide keys when options may be reordered. |
legend | string | Not set | Visible accessible name for the choice group. |
name | string | Not set | Name used by the component's native form controls. |
orientation | "horizontal" | | "vertical" | Layout direction and applicable arrow-key navigation direction. |
variant | "default" | "default" | Visual treatment within this component family. |
size | WlSizeSm | "md" | Size within the component family's documented scale. |
density | WlDensity | "default" | Spacing density for this component family. |
disabled | boolean | false | Disable user interaction with this component. |
invalid | boolean | false | Expose a validation error state on the control. |
loading | boolean | false | Indicate pending work supplied by the application. |
pt | WlPt< | Not set | Attributes and callbacks for the component's documented pass-through sections. |
Events
| Event | Payload | When emitted |
|---|---|---|
update:modelValue | WlOptionValue< | Emitted when the component requests a model change; the payload is the next value. |
Slots
| Slot | Type / values | Content |
|---|---|---|
legend | legend?(props: Record< | Custom accessible group legend. |
option | option?(props: { option: TOption; index: number; checked: boolean; disabled: boolean }): unknown; | Custom option content with its value and interaction state. |
Pass-through: pt
Sections WlRadioGroup are listed below. Attributes merge in this order: createWlPt() WlConfig.ptpt instance. Class and style merge; the last supplied value takes priority for other attributes.
| Section | DOM | Purpose |
|---|---|---|
root | fieldset.wl-choice-group | Main element of the component. |
legend | legend.wl-choice-group__legend | Visible name of the entire option group. |
options | div.wl-choice-group__options | Container holding the available controls. |
option | label.wl-checkline | One available option or its control wrapper. |
input | input.wl-check-input | Native input that receives focus and control attributes. |
Sections refer to the component DOM. Dotted names identify a configuration group and its section; composite parts use their own pt groups. Global and local attributes merge, with class and style added together.
Keyboard and accessibility
- Use a legend for the group and a readable label for each radio.
- Native radios share a form name; generated names are unique per instance.
- Tab enters the selected or first enabled radio; arrows choose the next enabled option.
Keyboard and application responsibilities
| Key | Action |
|---|---|
| Tab | Enter or leave the group through one active focus stop. |
| ← / → or ↑ / ↓ | Move in the configured orientation and skip disabled items. |
| Home / End | Focus the first or last enabled item. |
| Enter / Space | Activate the focused action. Tabs, radios and segmented choices select as documented. |
Provide a meaningful accessible name and connect labels, hints and errors to the focusable element. Check the behavior with your own data and a screen reader.
WAI-ARIA Authoring PracticesChanges are emitted through v-model. After selection, cancellation and reset, labels and states must remain clear.
In your application, check keyboard controls, zoom and focus visibility. State labels and required information must be readable in every theme.