<link href='https://fonts.googleapis.com/css?family=Roboto+Condensed:400,300' rel='stylesheet' type='text/css'>

<h1>Toggle.</h1>
<a href="#" class="toggle toggle--on"></a>
*, *:before,
*:after {
  box-sizing: border-box;
}

html {
  font-family: 'Roboto Condensed', sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  height: 100%;
  color: #ECEFF1;
  background-image: radial-gradient(lighten(#263238, 20%), #263238);
}

.toggle {
  position: relative;
  display: block;
  margin: 0 auto;
  width: 150px;
  height: 60px;
  color: white;
  outline: 0;
  text-decoration: none;
  border-radius: 100px;
  border: 2px solid #546E7A;
  background-color: #263238;
  transition: all 500ms;
  &:active {
    background-color: darken(#263238, 5%);
  }
  &:hover:not(.toggle--moving) {
    &:after {
      background-color: #455A64;
    }
  }
  &:after {
    display: block;
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 4px;
    width: calc(50% - 4px);
    line-height: 45px;
    text-align: center;
    text-transform: uppercase;
    font-size: 20px;
    color: white;
    background-color: #37474F;
    border: 2px solid;
    transition: all 500ms; 
  }
}
.toggle--on {
  &:after {
    content: 'On';
    border-radius: 50px 5px 5px 50px;
    color: #66BB6A;
  }
}
.toggle--off {
  &:after {
    content: 'Off';
    border-radius: 5px 50px 50px 5px;
    transform: translate(100%, 0);
    color: #f44336;
  }
}
.toggle--moving {
  background-color: darken(#263238, 5%);
  &:after {
    color: transparent;
    border-color: darken(#546E7A, 8%);
    background-color: darken(#37474F, 10%);
    transition: color 0s,
                transform 500ms,
                border-radius 500ms,          
                background-color 500ms;
  }
}


h1 {
  font-size: 64px;
  margin-top: 0;
  margin-bottom: 50px;
}
View Compiled
$('.toggle').click(function(e) {
  var toggle = this;
  
  e.preventDefault();
  
  $(toggle).toggleClass('toggle--on')
         .toggleClass('toggle--off')
         .addClass('toggle--moving');
  
  setTimeout(function() {
    $(toggle).removeClass('toggle--moving');
  }, 200)
});
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. //cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js