Skip to content

<XrRadioGroup> ​

A set of options of which one is chosen, all shown at once. Every row is a target at least the theme's minTarget tall, for every input: mouse, controller ray, pinch and fingertip.

Usage ​

vue
<script setup lang="ts">
const size = ref('Medium')
const plan = ref<string>()
</script>

<template>
  <XrRadioGroup v-model="size" direction="row" :options="['Small', 'Medium', 'Large']" />

  <XrRadioGroup
    v-model="plan"
    :options="[
      { label: 'Free', value: 'free', description: 'One room' },
      { label: 'Home', value: 'home', description: 'Every room' },
      { label: 'Office', value: 'office', disabled: true },
    ]"
  />
</template>

Options are strings (the label is the value) or XrRadioOption objects: { label, value, description?, disabled? }, the same shape as XrSelect's. Choosing another option emits update:modelValue and change; pressing the chosen one does nothing. Until modelValue matches an option, none is chosen.

direction="row" puts them side by side (wrapping when they do not fit), gap spaces them, disabled greys them all out.

With more than five or six options, or little room, use XrSelect.

API ​

Props ​

PropTypeDefaultDescription
direction"row" | "column"'column'Stack the options (column) or put them side by side (row).
gapSpaceValue1Space between the options: a step on the theme's scale, or "12px".
uiRecord<string, unknown>{}Escape hatch: raw uikit (@pmndrs/uikit) properties for the group, merged last.
disabledbooleanGreys out every option; none can be chosen.
partsPartial<Record<RadioPart, Record<string, unknown>>>Raw uikit properties per inner part of every option, merged after the defaults: option (the row), circle, dot, label, description.
optionsreadonly (string | XrRadioOption)[][]The choices: strings, or { label, value, description?, disabled? }.
modelValueXrRadioValueThe chosen option's value. Use with v-model.

Events ​

EventPayloadDescription
changevalue: XrRadioValue, option: XrRadioOptionAn option other than the current one was chosen.
update:modelValuevalue: XrRadioValueAn option was chosen (v-model).

MIT License