Vue Bootstrap Checks & radios Component

Checks & radios with Bootstrap Styling

Bootstrap 5 components designed for Vue.js

This component is part of the CoreUI for Vue.js UI components library, which offers all Bootstrap components designed to work seamlessly with Vue.js.

If you want to use Bootstrap 5 in a Vue.js environment while also needing advanced components that Bootstrap does not offer and dedicated developer support, then this library is the best solution for you.

Learn how to use CoreUI’s Vue Checks & radios component with Bootstrap styles for flexible, framework-consistent UI.

Approach

Browser default radios are replaced with the help of <CFormCheck radio>. Radios are for selecting one option from many.

Radios

Add the disabled attribute and the associated <label>s are automatically styled to match with a lighter color to help indicate the input’s state.

vue
<template>
  <CFormCheck id="flexRadioDefault1" type="radio" name="flexRadioDefault" label="Default radio" />
  <CFormCheck
    id="flexRadioDefault2"
    type="radio"
    name="flexRadioDefault"
    label="Checked radio"
    checked
  />
</template>

<script setup>
import { CFormCheck } from '@coreui/vue'
</script>

vModel

vue
<template>
  <CFormCheck id="flexRadioVModel1" v-model="picked" type="radio" inline label="One" value="One" />
  <CFormCheck id="flexRadioVModel2" v-model="picked" type="radio" inline label="Two" value="Two" />
  <CFormCheck
    id="flexRadioVModel3"
    v-model="picked"
    type="radio"
    inline
    label="Three"
    value="Three"
  />
  <CFormCheck
    id="flexRadioVModel4"
    v-model="picked"
    type="radio"
    inline
    label="Four"
    value="Four"
  />
  <CFormCheck
    id="flexRadioVModel5"
    v-model="picked"
    type="radio"
    inline
    label="Five"
    value="Five"
  />
  <div>Picked: {{ picked }}</div>
</template>

<script setup>
import { CFormCheck } from '@coreui/vue'
import { ref } from 'vue'
const picked = ref('Four')
</script>

Disabled

vue
<template>
  <CFormCheck
    id="flexRadioDisabled"
    type="radio"
    name="flexRadioDisabled"
    label="Disabled radio"
    disabled
  />
  <CFormCheck
    id="flexRadioCheckedDisabled"
    type="radio"
    name="flexRadioDisabled"
    label="Disabled checked radio"
    checked
    disabled
  />
</template>

<script setup>
import { CFormCheck } from '@coreui/vue'
</script>

Default (stacked)

By default, any number of radios that are immediate sibling will be vertically stacked and appropriately spaced.

vue
<template>
  <CFormCheck
    id="exampleRadios1"
    type="radio"
    name="exampleRadios"
    value="option1"
    label="Default radio"
    checked
  />
  <CFormCheck
    id="exampleRadios2"
    type="radio"
    name="exampleRadios"
    value="option2"
    label="Second default radio"
  />
  <CFormCheck
    id="exampleRadios3"
    type="radio"
    name="exampleRadios"
    value="option3"
    label="Disabled radio"
    disabled
  />
</template>

<script setup>
import { CFormCheck } from '@coreui/vue'
</script>

Inline

Group radios on the same horizontal row by adding inline boolean property to any <CFormCheck>.

vue
<template>
  <CFormCheck
    id="inlineCheckbox1"
    inline
    type="radio"
    name="inlineRadioOptions"
    value="option1"
    label="1"
  />
  <CFormCheck
    id="inlineCheckbox2"
    inline
    type="radio"
    name="inlineRadioOptions"
    value="option2"
    label="2"
  />
  <CFormCheck
    id="inlineCheckbox3"
    inline
    type="radio"
    name="inlineRadioOptions"
    value="option3"
    label="3 (disabled)"
    disabled
  />
</template>

<script setup>
import { CFormCheck } from '@coreui/vue'
</script>

Reverse

Put your radios on the opposite side by adding reverse boolean property.

vue
<template>
  <CFormCheck id="reverseOption1" reverse type="radio" value="option1" label="Reverse radio" />
  <CFormCheck
    id="reverseOption2"
    reverse
    type="radio"
    value="option2"
    label="Disabled reverse radio"
    disabled
  />
</template>

<script setup>
import { CFormCheck } from '@coreui/vue'
</script>

Without labels

Remember to still provide some form of accessible name for assistive technologies (for instance, using aria-label).

vue
<template>
  <CFormCheck id="radioNoLabel" type="radio" name="radioNoLabel" value="" aria-label="..." />
</template>

<script setup>
import { CFormCheck } from '@coreui/vue'
</script>

Toggle buttons

Create button-like radio buttons by using button boolean property on the <CFormCheck> component. These toggle buttons can further be grouped in a button group if needed.

vue
<template>
  <CFormCheck
    id="option1"
    :button="{ color: 'secondary' }"
    type="radio"
    name="options"
    autocomplete="off"
    label="Checked"
    checked
  />
  <CFormCheck
    id="option2"
    :button="{ color: 'secondary' }"
    type="radio"
    name="options"
    autocomplete="off"
    label="Radio"
  />
  <CFormCheck
    id="option3"
    :button="{ color: 'secondary' }"
    type="radio"
    name="options"
    autocomplete="off"
    label="Radio"
    disabled
  />
  <CFormCheck
    id="option4"
    :button="{ color: 'secondary' }"
    type="radio"
    name="options"
    autocomplete="off"
    label="Radio"
  />
</template>

<script setup>
import { CFormCheck } from '@coreui/vue'
</script>

Outlined styles

Different variants of button, such at the various outlined styles, are supported.

vue
<template>
  <CFormCheck
    id="success-outlined"
    :button="{ color: 'success', variant: 'outline' }"
    type="radio"
    name="options-outlined"
    autocomplete="off"
    label="Radio"
    checked
  />
  <CFormCheck
    id="danger-outlined"
    :button="{ color: 'danger', variant: 'outline' }"
    type="radio"
    name="options-outlined"
    autocomplete="off"
    label="Radio"
  />
</template>

<script setup>
import { CFormCheck } from '@coreui/vue'
</script>