Categories
Vue Answers

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

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *