How to add a radio button component with Vue.js?

Sometimes, we want to add a radio button component with Vue.js.

In this article, we’ll look at how to add a radio button component with Vue.js.

How to add a radio button component with Vue.js?

To add a radio button component with Vue.js, we can add an input with the type attribute set to radio.

For instance, we write

<template>
  <div>
    <input type="radio" value="label" name="name" v-model="value" />
  </div>
</template>

to add a radio button into our template by adding an input element with the type attribute set to radio.

We set the v-model to value to bind the radio buttons’s selected value to the value reactive property.

Conclusion

To add a radio button component with Vue.js, we can add an input with the type attribute set to radio.