WlRadioGroup

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

Appearance

Plan
basic

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

Plan
basic

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.

Plan

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>