Keyboard shortcut: Ctrl + K
Get started

Radio

VRadio selects one value from a set of options. Share the same name and v-model across the group for native selection and arrow navigation.

Usage

vue
<script setup lang="ts">
import { ref } from 'vue'
import { VRadio } from 'vectis-ui'

const plan = ref('standard')
</script>

<template>
  <VRadio v-model="plan" name="plan" value="free">Free</VRadio>
  <VRadio v-model="plan" name="plan" value="standard">Standard</VRadio>
  <VRadio v-model="plan" name="plan" value="pro">Pro</VRadio>
</template>

Examples

Hint

Use label or the default slot for the name. hint adds help text linked through aria-describedby.

vue

Three to five working days.

Next working day, when ordered before noon.

<script setup lang="ts">
import { ref } from 'vue'
import { VRadio } from 'vectis-ui'

const delivery = ref('standard')
</script>

<template>
  <div class="stack">
    <VRadio
      v-model="delivery"
      name="delivery"
      value="standard"
      label="Standard"
      hint="Three to five working days."
    />
    <VRadio
      v-model="delivery"
      name="delivery"
      value="express"
      label="Express"
      hint="Next working day, when ordered before noon."
    />
  </div>
</template>

<style scoped>
.stack {
  display: grid;
  justify-items: start;
  gap: var(--vectis-space-3);
}
</style>

Label position

labelPosition="start" places the label before the radio button.

vue
<script setup lang="ts">
import { ref } from 'vue'
import { VRadio } from 'vectis-ui'

const side = ref('end')
</script>

<template>
  <div class="stack">
    <VRadio v-model="side" name="label-side" value="end">Label after the dot, the default</VRadio>
    <VRadio v-model="side" name="label-side" value="start" label-position="start">
      Label before the dot
    </VRadio>
  </div>
</template>

<style scoped>
/* Keep the clickable label from stretching across the grid. */
.stack {
  display: grid;
  justify-items: start;
  gap: var(--vectis-space-2);
}
</style>

Full width

spread fills the available width and places the label and radio button at opposite ends.

vue
<script setup lang="ts">
import { ref } from 'vue'
import { VRadio } from 'vectis-ui'

const side = ref('start')
</script>

<template>
  <div class="settings">
    <VRadio v-model="side" name="spread-side" value="start" spread label-position="start">
      Label at the start, dot at the end
    </VRadio>
    <VRadio v-model="side" name="spread-side" value="end" spread>
      Dot at the start, label at the end
    </VRadio>
  </div>
</template>

<style scoped>
.settings {
  display: grid;
  gap: var(--vectis-space-3);
  inline-size: 100%;
  max-inline-size: 24rem;
  padding: var(--vectis-space-4);
  border: 1px solid var(--vectis-color-border);
  border-radius: var(--vectis-radius-surface);
}
</style>

Read-only

Set readonly on every option to keep the selection unchanged while arrows move focus. Use a named wrapper with role="radiogroup" and aria-readonly="true" to announce the state. A read-only group with required and no selection still fails native form validation.

vue
<script setup lang="ts">
import { ref } from 'vue'
import { VRadio } from 'vectis-ui'

const plan = ref('standard')
</script>

<template>
  <div class="stack">
    <!-- Arrow keys move focus without changing the selection. -->
    <VRadio v-model="plan" name="locked-plan" value="free" readonly label="Free" />
    <VRadio v-model="plan" name="locked-plan" value="standard" readonly label="Standard" />
    <VRadio v-model="plan" name="locked-plan" value="pro" readonly label="Pro" />
  </div>
</template>

<style scoped>
.stack {
  display: grid;
  justify-items: start;
  gap: var(--vectis-space-3);
}
</style>

Disabled

disabled prevents selection and removes the option from keyboard navigation and form submission.

vue
<script setup lang="ts">
import { ref } from 'vue'
import { VRadio } from 'vectis-ui'

const plan = ref('legacy')
</script>

<template>
  <div class="stack">
    <VRadio v-model="plan" name="plan-tier" value="free">Free</VRadio>
    <VRadio v-model="plan" name="plan-tier" value="pro" disabled>
      Pro, not available on this account
    </VRadio>
    <VRadio v-model="plan" name="plan-tier" value="legacy" disabled>
      Legacy, no longer offered
    </VRadio>
  </div>
</template>

<style scoped>
.stack {
  display: grid;
  justify-items: start;
  gap: var(--vectis-space-2);
}
</style>

API

Props

PropTypeDefault
valueItemValuenone
String or number assigned to v-model when selected. Use a distinct value for each option.
labelstringnone
Visible label, replaced by the default slot. Without either, provide aria-label or aria-labelledby.
hintstringnone
Help text below the label, linked through aria-describedby.
errorstringnone
Error message shown in place of the hint. Sets aria-invalid, is linked through aria-describedby and is announced when it appears.
labelPositionRadioLabelPosition'start' | 'end''end'
Label before the radio button with start, or after it with end.
spreadbooleanfalse
Fills the available width and separates the label and radio button.
invalidbooleanfalse
Sets aria-invalid and the error style. Does not block form submission by itself.
disabledbooleanfalse
Disables this option and excludes it from keyboard navigation and form submission.
readonlybooleanfalse
Prevents selection changes while preserving focus and native form behavior. Set on every option. Announce read-only state on the group wrapper.
v-modelItemValue''
Selected value, shared by the group. An option is selected when the model matches its value. Defaults to an empty string.

Slots

SlotType
default{}
Clickable label content, replacing label.

Types

Types used in the API tables. Import exported types from vectis-ui.

export type ItemValue = string | number

CSS variables

TokenValue
--vectis-control-size-check1.25rem
--vectis-control-size-check-dot0.5rem