Implementing Toggle Switch in Vue js using vue-js-toggle-button | Code2night.com
Code2night
  • Home
  • Blogs
  • Guest Posts
  • Tutorial
  • Post Blog
  • Register
  • Login
  1. Home
  2. Blogpost

Implementing Toggle Switch in Vue js using vue-js-toggle-button

Date- Aug 14,2021

6088

vue js toggle buttons

vue-js-toggle-button -

It is a npm package available for implementing toggle buttons. For installing this package you have to follow these steps:-

Step 1:-

First of all you have to install npm package using 


npm i vue-js-toggle-button

After you execute this command in the terminal, vue js toggle button package will be installed in your project. After it is completed we will move to second stop of importing the package and using in the component.

Step-2:-

So after the package is installed, you have to go to the main.js in your vue application and add these lines

import ToggleButton from 'vue-js-toggle-button'
  
Vue.use(ToggleButton)

Now , after adding these lines your vue application is ready to use vue-js-toggle-button. So now you have to go to the component where you want to add that toggle button.And add this line to your html.


<toggle-button @change="checkData($event )" :value="Boolean(tr.isActive)" :labels="{checked: 'Yes', unchecked: 'No'}" style="margin-left: 20px" />

Now  talking about this line, we are creating a toggle button and checkData($event)  will be a method where we will capture the toggle button value on change.So you have to add this in your methods

	methods: {	 
	     checkData( event) {
      let value = event.value; /*will return true or false*/
  
		    },
		}

So , this is how you can get the data of your toggle button .For setting the data we have used this. You have to pass true or false to set the value.  

:value="Boolean(tr.isActive)"

So this is how we can implement toggle button in our application. This will be the output

Comments

Tags

LinkedinLogin
LinkedinProfile
GetLinkedinProfile
C#
Aspnet
MVC
Linkedin
ITextSharp
Export to Pdf
AspNet Core
AspNet
View to Pdf in Aspnet
Model Validation In ASPNET Core MVC 60
Model Validation
Model Validation In ASPNET Core MVC
Model Validation In ASPNET
Image Compression in AspNet
Compress Image in c#
AspNet MVC
Free Download for Youtube Subscribers!

First click on Subscribe Now and then subscribe the channel and come back here.
Then Click on "Verify and Download" button for download link

Subscribe Now | 1190
Download
Support Us....!

Please Subscribe to support us

Thank you for Downloading....!

Please Subscribe to support us

Continue with Downloading
Be a Member
Join Us On Whatsapp Join Us On Facebook

Welcome To Code2night, A common place for sharing your programming knowledge,Blogs and Videos

  • Panipat
  • info@Code2night.com

Links

  • Home
  • Blogs
  • Tutorial
  • Post Blog

Popular Tags

Copyright © 2025 by Code2night. All Rights Reserved

  • Home
  • Blog
  • Login
  • SignUp
  • Contact
  • Terms & Conditions
  • Refund Policy
  • About Us
  • Privacy Policy
  • Json Beautifier
  • Guest Posts