Formulários

VRadioGroup

Componentev-model9 exemplos12 propsA2UI · RadioGroup

Seleção única entre opções mutuamente exclusivas, com layouts vertical, horizontal e card.

Importação
<script setup lang="ts">
import { VRadioGroup } from 'vueui-nova-kit'
</script>

Uso

Exemplo
<script setup lang="ts">

</script>

<template>
  
</template>

Playground

Os controles abaixo são gerados a partir das props declaradas em VRadioGroup.types.ts; o código acompanha cada mudança.

Exemplos

Variantes, tamanhos e estados, extraídos das stories da biblioteca.

Default

Variação Padrão. Estado padrão do componente; use a aba Controls para experimentar as props ao vivo. Props: modelValue="email", label="Notification method".

Ver código
vue
<script setup lang="ts">
import { ref } from 'vue'
import { VRadioGroup } from 'vueui-nova-kit'

const value = ref('email')
const options = [
  {
    value: 'email',
    label: 'Email notifications',
    description: 'Get notified via email',
  },
  {
    value: 'push',
    label: 'Push notifications',
    description: 'Get notified on your device',
  },
  {
    value: 'sms',
    label: 'SMS notifications',
    description: 'Get text message alerts',
  },
]
</script>

<template>
  <VRadioGroup
    v-model="value"
    :options="options"
    label="Notification method" />
</template>

Vertical

Variação Vertical. Props: modelValue="email", label="Choose a notification chann…", layout="vertical".

Ver código
vue
<script setup lang="ts">
import { ref } from 'vue'
import { VRadioGroup } from 'vueui-nova-kit'

const value = ref('email')
const options = [
  {
    value: 'email',
    label: 'Email notifications',
    description: 'Get notified via email',
  },
  {
    value: 'push',
    label: 'Push notifications',
    description: 'Get notified on your device',
  },
  {
    value: 'sms',
    label: 'SMS notifications',
    description: 'Get text message alerts',
  },
]
</script>

<template>
  <VRadioGroup
    v-model="value"
    :options="options"
    label="Choose a notification channel" />
</template>

Horizontal

Variação Horizontal. Props: modelValue="monthly", label="Billing cycle", layout="horizontal".

Ver código
vue
<script setup lang="ts">
import { ref } from 'vue'
import { VRadioGroup } from 'vueui-nova-kit'

const value = ref('monthly')
const options = [
  { value: 'monthly', label: 'Monthly' },
  { value: 'yearly', label: 'Yearly' },
  { value: 'lifetime', label: 'Lifetime' },
]
</script>

<template>
  <VRadioGroup
    v-model="value"
    layout="horizontal"
    :options="options"
    label="Billing cycle" />
</template>

Card

Variação Card. Props: modelValue="free", label="Choose a plan", layout="card".

Ver código
vue
<script setup lang="ts">
import { ref } from 'vue'
import { VRadioGroup } from 'vueui-nova-kit'

const value = ref('free')
const options = [
  {
    value: 'free',
    label: 'Free',
    description: 'For getting started',
  },
  {
    value: 'pro',
    label: 'Pro',
    description: 'More features',
  },
  {
    value: 'business',
    label: 'Business',
    description: 'Advanced controls',
  },
]
</script>

<template>
  <VRadioGroup
    v-model="value"
    layout="card"
    :options="options"
    label="Choose a plan" />
</template>

Plans

Variação Plans. Props: modelValue="personal", label="Choose a plan".

Ver código
vue
<script setup lang="ts">
import { ref } from 'vue'
import { VRadioGroup } from 'vueui-nova-kit'

const value = ref('personal')
const options = [
  {
    value: 'personal',
    label: 'Personal plan',
    description: 'For individuals',
  },
  {
    value: 'team',
    label: 'Team plan',
    description: 'For small teams',
  },
  {
    value: 'enterprise',
    label: 'Enterprise',
    description: 'For large organizations',
  },
]
</script>

<template>
  <VRadioGroup v-model="value" :options="options" label="Choose a plan" />
</template>

Error

Variação Erro. Props: modelValue="", label="Choose a plan", required=true, errorMessage="Please select a plan to con…".

Ver código
vue
<script setup lang="ts">
import { VRadioGroup } from 'vueui-nova-kit'

const options = [
  {
    value: 'personal',
    label: 'Personal plan',
    description: 'For individuals',
  },
  {
    value: 'team',
    label: 'Team plan',
    description: 'For small teams',
  },
  {
    value: 'enterprise',
    label: 'Enterprise',
    description: 'For large organizations',
  },
]
</script>

<template>
  <VRadioGroup
    v-model="value"
    :options="options"
    label="Choose a plan"
    required
    error-message="Please select a plan to continue." />
</template>

Disabled

Variação Desabilitado. Props: modelValue="team", label="Choose a plan", disabled=false.

Ver código
vue
<script setup lang="ts">
import { ref } from 'vue'
import { VRadioGroup } from 'vueui-nova-kit'

const value = ref('team')
const options = [
  {
    value: 'personal',
    label: 'Personal plan',
    description: 'For individuals',
    disabled: false,
  },
  {
    value: 'team',
    label: 'Team plan',
    description: 'For small teams',
    disabled: true,
  },
  {
    value: 'enterprise',
    label: 'Enterprise',
    description: 'For large organizations',
    disabled: false,
  },
]
</script>

<template>
  <VRadioGroup v-model="value" :options="options" label="Choose a plan" />
</template>

Group Disabled

Variação Grupo desabilitado. Props: modelValue="email", label="Notification method", disabled=true.

Ver código
vue
<script setup lang="ts">
import { ref } from 'vue'
import { VRadioGroup } from 'vueui-nova-kit'

const value = ref('email')
const options = [
  {
    value: 'email',
    label: 'Email notifications',
    description: 'Get notified via email',
  },
  {
    value: 'push',
    label: 'Push notifications',
    description: 'Get notified on your device',
  },
  {
    value: 'sms',
    label: 'SMS notifications',
    description: 'Get text message alerts',
  },
]
</script>

<template>
  <VRadioGroup
    v-model="value"
    :options="options"
    label="Notification method"
    disabled />
</template>

Sizes

Variação Tamanhos. Interativo: o estado é mantido na própria story (v-model).

Ver código
vue
<script setup lang="ts">
import { ref } from 'vue'
import { VRadioGroup } from 'vueui-nova-kit'

const sm = ref('email')
const md = ref('email')
const lg = ref('email')
const notificationOptions = [
  {
    value: 'email',
    label: 'Email notifications',
    description: 'Get notified via email'
  },
  {
    value: 'push',
    label: 'Push notifications',
    description: 'Get notified on your device'
  },
  {
    value: 'sms',
    label: 'SMS notifications',
    description: 'Get text message alerts'
  }
]
</script>

<template>
  <div style="display:flex;flex-direction:column;gap:20px;max-width:480px">
    <VRadioGroup v-model="sm" size="sm" label="Small" :options="notificationOptions" />
    <VRadioGroup v-model="md" size="md" label="Medium" :options="notificationOptions" />
    <VRadioGroup v-model="lg" size="lg" label="Large" :options="notificationOptions" />
  </div>
</template>

Acessibilidade

fieldset + legend, inputs nativos type="radio", Tab e arrow keys, foco visível, área mínima 44×44px, aria-invalid no erro.

Estados

Unselected · Hover · Focus · Selected · Pressed · Disabled · Disabled Selected · Error.

Motion

TriggerPropertyDurationEasing
Hoverborder-color100msease-out
Selectdot scale/opacity140msstandard
Focus ringbox-shadow120msease-out
Pressedtransform scale70msease-in
Card selectbackground/border140msease-out

Respeitar prefers-reduced-motion.

Todas as transições respeitam prefers-reduced-motion e os tokens --v-duration-*.

Props

PropTipoDefaultDescrição
modelValuestring""—
options*VRadioOption[][]—
labelstring——
descriptionstring——
errorMessagestring——
disabledbooleanfalse—
sizeVRadioGroupSize"md"—
layoutVRadioGroupLayout"vertical"—
namestring——
idstring——
requiredbooleanfalse—
motionVMotionLevelV_MOTION_DEFAULT ("expressive")—

Events

EventoPayloadDescrição
@update:modelValuevalue: string—
@changevalue: string—

Slots

Sem slots.

Fonte: src/components/form/VRadioGroup/VRadioGroup.vue · tipos: src/components/form/VRadioGroup/VRadioGroup.types.ts