Skip to content

Radio - Flowbite Vue ​

Get started with the radio component to let the user choose a single option from multiple options in the form of a circle based on multiple styles and colors ​


Radio - Flowbite

Original reference: https://flowbite.com/docs/forms/radio/

The radio component can be used to allow the user to choose a single option from one or more available options coded with the utility classes from Tailwind CSS and available in multiple styles, variants, and colors and support dark mode.

Default Radio ​

Use FwbRadio with v-model and a value prop to let the user select a single option. Pass name directly on each radio when used standalone, or use FwbRadioGroup to share it automatically across child radios.

vue
<template>
  <fwb-radio v-model="picked" name="radio" label="Radio 1" value="one" />
  <fwb-radio v-model="picked" name="radio" label="Radio 2" value="two" />
</template>

<script setup>
import { ref } from 'vue'
import { FwbRadio } from 'flowbite-vue'

const picked = ref()
</script>

Disabled State ​

Set the disabled prop to prevent the user from selecting the radio. Disabled styling is applied automatically to both the input and the label text.

vue
<template>
  <fwb-radio v-model="picked" disabled label="Disabled radio" name="radio-disabled" value="one" />
  <fwb-radio v-model="picked" disabled label="Disabled checked" name="radio-disabled" value="two" />
</template>

<script setup>
import { ref } from 'vue'
import { FwbRadio } from 'flowbite-vue'

const picked = ref('two')
</script>

Radio Group ​

Use FwbRadioGroup to wrap related radio buttons. The name prop on the group is shared across all child radios automatically, so you don't need to repeat it on each one.

Pick a fruit

Selected: banana

vue
<template>
  <fwb-radio-group name="fruit" label="Pick a fruit">
    <fwb-radio
      v-for="fruit in fruits"
      :key="fruit.value"
      v-model="picked"
      :label="fruit.label"
      :value="fruit.value"
    />
  </fwb-radio-group>
</template>

<script setup>
import { ref } from 'vue'
import { FwbRadio, FwbRadioGroup } from 'flowbite-vue'

const fruits = [
  { label: 'Apple', value: 'apple' },
  { label: 'Banana', value: 'banana' },
  { label: 'Orange', value: 'orange' },
]

const picked = ref('banana')
</script>

Inline Radio ​

Place multiple FwbRadio components inside a flex wrapper to lay them out horizontally side by side.

vue
<template>
  <div class="flex gap-2">
    <fwb-radio v-model="picked" label="Inline 1" name="inline-radio" value="first" />
    <fwb-radio v-model="picked" label="Inline 2" name="inline-radio" value="second" />
    <fwb-radio v-model="picked" label="Inline 3" name="inline-radio" value="third" />
    <fwb-radio v-model="picked" label="Inline 4" name="inline-radio" value="fourth" />
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { FwbRadio } from 'flowbite-vue'

const picked = ref('first')
</script>

Use the default slot instead of the label prop when the label contains rich content such as links.

vue
<template>
  <fwb-radio v-model="picked" name="with-link" value="first">
    I agree with the
    <fwb-a class="ml-1" href="#">terms and conditions</fwb-a>.
  </fwb-radio>
</template>

<script setup>
import { ref } from 'vue'
import { FwbA, FwbRadio } from 'flowbite-vue'

const picked = ref()
</script>

Radio List Group ​

Use FwbListGroup and FwbListGroupItem to display radio buttons inside a vertical grouped list.

Selected: Vue JS

vue
<template>
  <fwb-list-group>
    <fwb-list-group-item v-for="option in options" :key="option.value">
      <fwb-radio
        v-model="picked"
        :label="option.label"
        name="list-radio"
        :value="option.value"
        wrapper-class="-mx-4 -my-2 w-full px-4 py-2"
      />
    </fwb-list-group-item>
  </fwb-list-group>
</template>

<script setup>
import { ref } from 'vue'
import { FwbListGroup, FwbListGroupItem, FwbRadio } from 'flowbite-vue'

const options = [
  { label: 'Angular', value: 'Angular' },
  { label: 'React', value: 'React' },
  { label: 'Svelte', value: 'Svelte' },
  { label: 'Vue JS', value: 'Vue JS' },
]

const picked = ref('Vue JS')
</script>

Horizontal List Group ​

Nest FwbRadio components inside a horizontal <ul> to create a full-width inline list selection.

Selected: vue

vue
<template>
  <ul class="w-full items-center rounded-lg border border-gray-200 bg-white text-sm font-medium text-gray-900 dark:border-gray-600 dark:bg-gray-700 dark:text-white sm:flex">
    <li
      v-for="option in options"
      :key="option.value"
      class="flex w-full border-b border-gray-200 last:border-b-0 dark:border-gray-600 sm:border-b-0 sm:border-r sm:last:border-r-0"
    >
      <fwb-radio
        v-model="picked"
        :label="option.label"
        name="radio-horizontal"
        :value="option.value"
        wrapper-class="w-full py-2 pl-3"
      />
    </li>
  </ul>
</template>

<script setup>
import { ref } from 'vue'
import { FwbRadio } from 'flowbite-vue'

const options = [
  { label: 'Angular', value: 'angular' },
  { label: 'React', value: 'react' },
  { label: 'Svelte', value: 'svelte' },
  { label: 'Vue JS', value: 'vue' },
]

const picked = ref('vue')
</script>

Bordered radio ​

Apply border styling directly to FwbRadio via wrapper-class to create a card-style selection option — no external wrapper element is needed.

vue
<template>
  <div class="grid grid-cols-2 gap-6">
    <fwb-radio
      v-model="picked"
      label="Radio 1"
      name="radio-bordered"
      value="one"
      wrapper-class="rounded border border-gray-200 p-2 dark:border-gray-700"
    />
    <fwb-radio
      v-model="picked"
      label="Radio 2"
      name="radio-bordered"
      value="two"
      wrapper-class="rounded border border-gray-200 p-2 dark:border-gray-700"
    />
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { FwbRadio } from 'flowbite-vue'

const picked = ref('one')
</script>

Validation ​

Use validationStatus on FwbRadioGroup together with the validationMessage slot (rich content) or the validationMessage prop (plain string) to show success or error feedback below the group. The slot takes priority when both are given.

Pick a fruit (success)

Great! You selected a fruit.

Pick a fruit (error)

Required! Please select a fruit to continue.

vue
<template>
  <div class="space-y-6">
    <fwb-radio-group name="fruit-success" label="Pick a fruit (success)" validation-status="success">
      <fwb-radio v-model="picked1" label="Apple" value="apple" />
      <fwb-radio v-model="picked1" label="Banana" value="banana" />
      <template #validationMessage>
        <span class="font-medium">Great!</span> You selected a fruit.
      </template>
    </fwb-radio-group>

    <fwb-radio-group
      name="fruit-error"
      label="Pick a fruit (error)"
      validation-message="Required! Please select a fruit to continue."
      validation-status="error"
    >
      <fwb-radio v-model="picked2" label="Apple" value="apple" />
      <fwb-radio v-model="picked2" label="Banana" value="banana" />
    </fwb-radio-group>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { FwbRadio, FwbRadioGroup } from 'flowbite-vue'

const picked1 = ref('banana')
const picked2 = ref('')
</script>

Helper text ​

Use the helper slot on FwbRadioGroup to show a hint below the group.

Shipping method

Delivery times are estimates and may vary during peak seasons.

vue
<template>
  <fwb-radio-group name="shipping" label="Shipping method">
    <fwb-radio v-model="picked" label="Standard (3–5 days)" value="standard" />
    <fwb-radio v-model="picked" label="Express (1–2 days)" value="express" />
    <template #helper>
      Delivery times are estimates and may vary during peak seasons.
    </template>
  </fwb-radio-group>
</template>

<script setup>
import { ref } from 'vue'
import { FwbRadio, FwbRadioGroup } from 'flowbite-vue'

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

Styling ​

Use dedicated props to pass classes to individual elements.

Custom styled group
vue
<template>
  <fwb-radio-group
    name="styled"
    label="Custom styled group"
    wrapper-class="bg-amber-300 dark:bg-green-800 p-3 pt-2 border-2 border-amber-700 dark:border-green-400 rounded-lg"
    legend-class="mb-0 px-2 font-bold text-amber-900 dark:text-green-200"
  >
    <fwb-radio
      v-model="picked"
      label="Option A"
      value="a"
      class="text-amber-600 dark:text-green-500 focus:ring-amber-500 dark:focus:ring-green-400"
      label-class="text-amber-900 dark:text-green-200"
    />
    <fwb-radio
      v-model="picked"
      label="Option B"
      value="b"
      class="text-amber-600 dark:text-green-500 focus:ring-amber-500 dark:focus:ring-green-400"
      label-class="text-amber-900 dark:text-green-200"
    />
  </fwb-radio-group>
</template>

<script setup>
import { ref } from 'vue'
import { FwbRadio, FwbRadioGroup } from 'flowbite-vue'

const picked = ref('a')
</script>

Radio component API ​

FwbRadio Props ​

Native attribute passthrough

FwbRadio sets inheritAttrs: false and forwards all extra attributes (e.g. form, aria-label) directly to the <input type="radio"> element. When using radios outside a FwbRadioGroup, pass name as either a prop or an attribute.

NameTypeDefaultDescription
classString | Object''Added to the radio input element.
disabledBooleanfalseDisables the radio.
labelString''Label text rendered next to the radio. Ignored when the default slot is used.
labelClassString | Object''Added to the label text element.
modelValueAny—The current value (use with v-model).
nameString''Groups radio buttons together. Inherited from FwbRadioGroup when omitted.
valueString''The value this radio represents.
wrapperClassString | Object''Added to the outer <label> element.

Accessibility

When a FwbRadio is inside a FwbRadioGroup with validationStatus="error", aria-invalid="true" is set automatically on the input — you do not need to set it manually on individual radios. aria-describedby is managed at the fieldset level by FwbRadioGroup. For radios without a visible label, pass aria-label as an attribute — it is forwarded directly to the <input type="radio">.

FwbRadio Slots ​

NameDescription
defaultRich label content rendered next to the radio (takes priority over label prop).

RadioGroup component API ​

FwbRadioGroup Props ​

Accessibility

FwbRadioGroup renders as a <fieldset> with a <legend>. aria-invalid="true" is set on every child FwbRadio when validationStatus="error". aria-describedby on the fieldset is wired to the IDs of any rendered validationMessage (slot or prop) and helper slots.

NameTypeDefaultDescription
labelString''Legend text for the group. Ignored when the legend slot is used.
legendClassString | Object''Added to the <legend> element.
nameString—Required. Shared name attribute provided to all child FwbRadio inputs.
validationMessageStringundefinedValidation feedback text; fallback for the validationMessage slot.
validationStatus'success' | 'error'undefinedApplies success or error colour styles and sets aria-invalid on child radios.
wrapperClassString | Object''Added to the outer <fieldset> element.

FwbRadioGroup Slots ​

NameDescription
defaultContainer for FwbRadio instances.
legendRich legend content (takes priority over label prop).
helperHelper text rendered below the group.
validationMessageValidation feedback rendered below the group (styled by validationStatus). Takes priority over the validationMessage prop.

Released under the MIT License.