WlRadioGroup

A labelled radio group with one selected option and shared keyboard navigation.
Components / Inputs v1.0.0-rc.1

Change props to see the result: the example and code use the same settings. “Reset” restores the initial values.

Settings

legend

Visible accessible name for the choice group.

name

Name used by the component's native form controls.

Disable user interaction with this component.

Expose a validation error state on the control.

Indicate pending work supplied by the application.

Props options, optionLabel, optionValue, optionDisabled, optionKey, orientation, variant, size, density, pt, models, handlers and slots can be edited in the SFC. See their descriptions in API.

Example

Plan

Choose a plan.

—

Tab enters the selected or first enabled radio; arrows choose the next enabled option.

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 { 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>

One plan from a labelled group

A labelled radio group with one selected option and shared keyboard navigation.

Plan

Choose a plan.

—

Tab enters the selected or first enabled radio; arrows choose the next enabled option.

Vue SFC · additional 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>