WlRadio
Radio button; value is the option value and v-model is the selection.
Change props to see the result: the example and code use the same settings. “Reset” restores the initial values.
Settings
name
Native group name.
Disables the radio button.
Error state.
Props value, pt, size, density, models, handlers and slots can be edited in the SFC. See their descriptions in API.
Example
Focus: outside the example · pointer: outside the example
Explore the live example and copy its Vue SFC into your application. Settings on the left can be combined.
Code for your application
Vue SFC · current settings
<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.
Vue SFC · additional 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-title">{{ "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-title">{{ "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>