WlRadio
States
Full example
<script setup lang="ts">
import { WlRadio } from "legato-ui";
import { useWlId } from "legato-ui/composables";
import { ref } from "vue";
const value = ref<string>("team");
const name = `example-access-${useWlId()}`;
</script>
<template>
<div class="wl-stack" data-space="md">
<WlRadio
v-model="value"
value="team"
:name="name"
size="sm"
>{{ "Entire team" }}</WlRadio><WlRadio
v-model="value"
value="private"
:name="name"
size="sm"
>{{ "Only me" }}</WlRadio>
</div>
</template>Size and density
Full example
<script setup lang="ts">
import { WlRadio } from "legato-ui";
import { useWlId } from "legato-ui/composables";
import { ref } from "vue";
const value = ref<string>("team");
const name = `example-access-${useWlId()}`;
</script>
<template>
<div class="wl-stack" data-space="md">
<WlRadio
v-model="value"
value="team"
:name="name"
size="sm"
>{{ "Entire team" }}</WlRadio><WlRadio
v-model="value"
value="private"
:name="name"
size="sm"
>{{ "Only me" }}</WlRadio>
</div>
</template>Selection groups
Two groups with a shared name within each, slot labels, required selection, invalid and an unavailable option.
Access: team. Format: not selected.
Full example
<script setup lang="ts">
import { WlButton, WlRadio } from "legato-ui";
import { ref } from "vue";
const visibility = ref<string>("team");
const format = ref<string | null>(null);
</script>
<template>
<div class="wl-stack" data-space="xl" data-input-example="WlRadio">
<fieldset class="docs-radio-group wl-stack" data-space="md">
<legend class="wl-text-subheading">{{ "One value for the entire group" }}</legend>
<WlRadio v-model="visibility" name="docs-input-visibility" value="personal">{{ "Only me" }}</WlRadio>
<WlRadio v-model="visibility" name="docs-input-visibility" value="team">{{ "Team" }}</WlRadio>
<WlRadio
v-model="visibility"
name="docs-input-visibility"
value="public"
disabled
>{{ "Everyone — temporarily unavailable" }}</WlRadio>
<p class="wl-text-small wl-text-muted">{{ "A shared name groups native radio inputs. Arrow keys change the selection within the group; Space selects the focused item." }}</p>
</fieldset>
<fieldset class="docs-radio-group wl-stack" data-space="md" :aria-describedby="format == null ? 'docs-radio-error' : undefined">
<legend class="wl-text-subheading">{{ "Required selection and invalid" }}</legend>
<WlRadio
v-model="format"
name="docs-input-format"
value="pdf"
:invalid="format == null"
:aria-describedby="format == null ? 'docs-radio-error' : undefined"
required
>{{ "PDF document" }}</WlRadio>
<WlRadio
v-model="format"
name="docs-input-format"
value="text"
:invalid="format == null"
:aria-describedby="format == null ? 'docs-radio-error' : undefined"
required
>{{ "Text file" }}</WlRadio>
<p
v-if="format == null"
id="docs-radio-error"
class="wl-text-small"
role="alert"
>{{ "Choose an export format." }}</p>
</fieldset>
<WlButton size="sm" @click="visibility = 'team'; format = null">{{ "Reset groups" }}</WlButton>
<p class="wl-text-small" role="status">{{
"Access:"
}} {{
visibility
}}{{
". Format:"
}} {{
format ?? "not selected"
}}.</p>
</div>
</template>
<style scoped>
.docs-radio-group { min-width: 0; margin: 0; padding: 0; border: 0; }
.docs-radio-group legend { margin-bottom: var(--wl-space-md); }
</style>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: ValueThe group model defines the value type; the consumer defines nullable models. No default.
| Prop | Type / values | Default | Purpose |
|---|---|---|---|
value * | Value | Required | Option value (any type). |
name | string | Not set | Native group name. |
disabled | boolean | false | Disables the radio button. |
invalid | boolean | false | Error state. |
pt | WlPt< | Not set | Attributes of internal Legato UI elements. |
size | WlSwitchSize | "md" | Size within the component family's documented scale. |
density | WlDensity | "default" | Spacing density for this component family. |
Events
| Event | Payload | When emitted |
|---|---|---|
update:modelValue | Value | Emitted when the component requests a model change; the payload is the next value. |
Slots
| Slot | Type / values | Content |
|---|---|---|
default | — | Label next to the radio button. |
Pass-through: pt
Sections WlRadio 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 |
|---|---|---|
input | input.wl-check-input | The input section in WlConfig.pt.radio configuration. |
box | span.wl-radio__box | The box section in WlConfig.pt.radio configuration. |
icon | span.wl-radio__icon | The icon section in WlConfig.pt.radio configuration. |
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
- The label is in the default slot; group options with fieldset/legend or a named group.
- A shared name enables native keyboard navigation between radio options; arrows change options and Space selects.
- One model stores the selected option's value. Independent groups need separate name values and models.
- Explain invalid in text and associate it with options through aria-describedby. disabled prevents selection of an individual item.
Keyboard and application responsibilities
| Key | Action |
|---|---|
| Tab / Shift+Tab | Focus an enabled native control. |
| Space | Change the current choice. |
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.