Create toggle button using bootstrap

728 0 0 0

Last Updated : 2024-04-19 09:56:41

You can only add the .min.css & .min.js files from the following library to your head code of the page and you will have a toggle button from a check-box. The only thing you need to do for a check-box to be turned into a toggle button is to add the ( data-toggle="toggle" ) attribute to it. Reference : https://www.bootstraptoggle.com/

<!-- In head tag --> 
<link href="https://gitcdn.github.io/bootstrap-toggle/2.2.2/css/bootstrap-toggle.min.css" rel="stylesheet">
<script src="https://gitcdn.github.io/bootstrap-toggle/2.2.2/js/bootstrap-toggle.min.js"></script>

<!-- In body tag -->
<input type="checkbox" checked data-toggle="toggle">

<!-- In turned off by default -->
<input type="checkbox" data-toggle="toggle">

<!-- to turn it on or off just add checked attibute -->

Reference: https://www.bootstraptoggle.com/

Mohammed Anwar

Mohammed Anwar

Experienced technical lead PHP, MySQL and Laravel Developer for 15+ years, with proven ability to develop and create high-quality and optimized web applications. Great ability to build and optimize database design, schema and queries. Versed programing trainer and instructor delivering web courses and helping others to get into the field in a timely manner. Fast and eager learner for new technologies .