toggle switch with multicolor line, Toggle, with check and close icon using fontawsome

toggle switch with multicolor line, Toggle, with check and close icon using fontawsome

by Ayyappan Sakthivadivel

HTML

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="checkbox-bar-holder">
  <input type="checkbox" id="toggle"/>
  <div class="checkbox-bar">
    <label for="toggle"></label>
  </div>
</div>

CSS

body{
  margin: 0;
}
.checkbox-bar-holder input[type="checkbox"] {
  display: none;
}

/*Button is :CHECKED*/

.checkbox-bar-holder input[type="checkbox"]:checked ~ .checkbox-bar {
  background: #05FF00;
  box-shadow: inset 2px 0px 2px rgba(0, 0, 0, 0.15);
}

.checkbox-bar-holder input[type="checkbox"]:checked ~ .checkbox-bar label {
  left: 35px;
  /* transform: rotate(360deg); */
}

/*'un':checked state*/

.checkbox-bar {
  width: 43px;
  height: 12px;
  background: #ff0000;
  font: normal normal normal 14px/1 FontAwesome;
  border-radius: 50px;
  box-shadow: inset 2px 0px 2px rgba(0, 0, 0, 0.5);
  transition: 400ms all ease-in-out 50ms;
  margin-top: 3px;
}

.checkbox-bar label {
    height: 18px;
    cursor: pointer;
    transition: 400ms all ease-in-out 50ms;
    box-sizing: border-box;
    backface-visibility: hidden;
    border-radius: 18px;
    width: 100%;
    /* border: #f00 solid 1px; */
    float: left;
}

.checkbox-bar label::before {
  content: "\f00d";
}



.checkbox-bar label::before,
.checkbox-bar label::after{
  height: 18px;
  width: 18px;
  font-size: 10px;
  background-color: #155A75;
  color: #fff;
  border-radius: 18px;
  display: flex;
  justify-content: center;
  align-items: center;
  top: -3px;
  position: relative;
  box-shadow: 0px 0px 2px rgba(0, 0, 0, 0.12), 0px 2px 2px rgba(0, 0, 0, 0.24);
}

/* pesduo class on toggle */

.checkbox-bar-holder input[type="checkbox"]:checked ~ .checkbox-bar label::before{
  content: "\f00c";
  right: -25px;
  position: relative;
  float: left;
}