Code2night
  • Home
  • Guest Posts
  • Tutorial
  • Languages
    • Angular
    • C
    • C#
    • HTML/CSS
    • Java
    • JavaScript
    • Node.js
    • Python
    • React
    • SQL Server
    • TypeScript
  • Post Blog
  • Tools
    • JSON Beautifier
    • HTML Beautifier
    • XML Beautifier
    • CSS Beautifier
    • JS Beautifier
    • PDF Editor
  • Register
  • Login
  1. Home
  2. Blogpost

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

Date- Aug 14,2021

8439

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

S
Shubham Batra
Programming author at Code2Night — sharing tutorials on ASP.NET, C#, and more.
View all posts →

Related Articles

Real Time Chat using SignalR with .Net core and Vue.js
Aug 15, 2021
How to reload child components in vue.js
May 15, 2021

Comments

Tags

Swagger UI
Swashbuckle
SwashbuckleAspNetCore
Rest API
Postman
Api Testing
ITextSharp
Export to Pdf
AspNet Core
AspNet
C#
View to Pdf in Aspnet
Scheduler
Fibonacci series in Java
Display Fibonacci Series
First C# Program
What is C?
C
C Programming
CodeLobster
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 | 1760
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
Code2Night

A community platform for sharing programming knowledge, tutorials, and blogs. Learn, write, and grow with developers worldwide.

Panipat, India   info@code2night.com

Quick Links
  • Home
  • Blogs
  • Tutorials
  • About Us
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Guest Posts
Dev Tools
  • JSON Beautifier
  • HTML Beautifier
  • XML Beautifier
  • CSS Beautifier
  • JS Beautifier
  • PDF Editor
By Language
  • Angular
  • C
  • C#
  • HTML/CSS
  • Java
  • JavaScript
  • Node.js
  • Python
  • React
  • SQL Server
  • TypeScript
© 2026 Code2Night. All Rights Reserved.
Built with for developers