<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
| Prop | Type | Default | Description |
|---|---|---|---|
direction | "row" | "column" | 'column' | Stack the options (column) or put them side by side (row). |
gap | SpaceValue | 1 | Space between the options: a step on the theme's scale, or "12px". |
ui | Record<string, unknown> | {} | Escape hatch: raw uikit (@pmndrs/uikit) properties for the group, merged last. |
disabled | boolean | Greys out every option; none can be chosen. | |
parts | Partial<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. | |
options | readonly (string | XrRadioOption)[] | [] | The choices: strings, or { label, value, description?, disabled? }. |
modelValue | XrRadioValue | The chosen option's value. Use with v-model. |
Events
| Event | Payload | Description |
|---|---|---|
change | value: XrRadioValue, option: XrRadioOption | An option other than the current one was chosen. |
update:modelValue | value: XrRadioValue | An option was chosen (v-model). |