JSFiddle - React, Tailwind, and code Playground
HTML
<div class="establishment-card">
<ul>
<li class="tg-list-item">
<input class="tgl tgl-flat" id="cb4" type="checkbox" /><label class="tgl-btn" for="cb4"></label><h4>Submit application for <strong>Establishment Card</strong> at <strong>GDRFA</strong> along with the current procedure</h4>
</li>
</ul>
</div>
CSS
.tgl {
display: none;
}
.tgl, .tgl:after, .tgl:before, .tgl *, .tgl *:after, .tgl *:before, .tgl + .tgl-btn {
box-sizing: border-box;
}
.tgl::selection, .tgl:after::selection, .tgl:before::selection, .tgl *::selection, .tgl *:after::selection, .tgl *:before::selection, .tgl + .tgl-btn::selection {
background: none;
}
.tgl + .tgl-btn {
outline: 0;
display: block;
width: 4em;
height: 2em;
position: relative;
cursor: pointer;
user-select: none;
margin-top: 7px;
}
.tgl + .tgl-btn:after, .tgl + .tgl-btn:before {
position: relative;
display: block;
content: "";
width: 50%;
height: 100%;
}
.tgl + .tgl-btn:after {
left: 0;
}
.tgl + .tgl-btn:before {
display: none;
}
.tgl:checked + .tgl-btn:after {
left: 50%;
}
.tg-list {
text-align: center;
display: flex;
align-items: center;
}
.tg-list-item {
margin: 0 2em;
}
.tgl-flat + .tgl-btn {
padding: 2px;
transition: all .2s ease;
background: #fff;
border: 4px solid #b9b9b9;
border-radius: 2em;
}
.tgl-flat + .tgl-btn:after {
transition: all .2s ease;
background: #b9b9b9;
content: "";
border-radius: 1em;
}
.establishment-card {
border: 1px solid #eee;
float: right;
padding: 10px;
width: 310px;
}
.tg-list-item h4 {
float: left;
color: #000;
padding-left: 65px;
margin-right: -8px;
}
.tgl-flat:checked + .tgl-btn {
border: 4px solid #7FC6A6;
}
.tgl-flat:checked + .tgl-btn:after {
left: 50%;
background: #7FC6A6;
}
.tgl-flat:checked + .tg-list-item h4 {
color: #7FC6A6;
}
.tgl-flat:checked + .establishment-card:after {
border: 1px solid #7FC6A6;
}
JavaScript
function myFunction() {
// Get the checkbox
var checkBox = document.getElementById("cb4");
// Get the output text
var text = document.getElementById("chk-text");
// If the checkbox is checked, display the output text
if (checkBox.checked == true){
text.style.color = "green";
} else {
text.style.color = "black";
}
}