Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <link href='https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,300,700,600,800,400' rel='stylesheet' type='text/css'>

<div ng-app="app">
<h2>Switches</h2>
  <br />
  <div ng-controller="AppCtrl">
    <div ng-repeat="color in ['primary', 'success', 'warning', 'danger']">
         <div ng-repeat="size in ['sm', 'md', 'lg']"
           style="margin-right:10px;"
          class="vrb-switch vrb-switch--{{color}} vrb-switch--{{size}}" ng-model="switches[$index].isOn"></div>
      <div ng-repeat="size in ['sm', 'md', 'lg']"
        style="margin-right:10px;"
       class="vrb-switch vrb-switch--{{color}} vrb-switch--{{size}} vrb-switch--circle" ng-model="switches[$index].isOn"></div>
      <br /><br />
    </div>
  </div>
  
</div>
<br /><br />



              
            
!

CSS

              
                @import "compass/css3";

$name-space: "vrb";
$base-spacing-unit: 5px;
$base-border-width: 2px;

$white: #F7F9F9;
$mono-lighter: #E1E4E5;
$mono-light: #BBC2C4;
$mono: #939DA0;
$mono-dark: #536066;
$mono-darker: #323C3F;

$brand-primary: #046999;
$brand-primary-shadow: #035366;

$brand-success: #56B881;
$brand-success-shadow: #418C59;

$brand-warning: #E57244;
$brand-warning-shadow: #AA4133;

$brand-info: #B0DDF2;
$brand-info-shadow: #89AFBC;

$h1: 35px;
$h2: 28px;
$h3: 24px;
$h4: 21px;
$h5: 18px;
$h6: 14px;

$paragraph: 14px;
$paragraph-lead: 18px;

html {
  margin: 0;
  padding: 0;
  background: $white;
  font-family: 'Open Sans', sans-serif;
}

* {
  box-sizing: border-box;
}

/**
*
* Base Typography
*
**/

[#{$name-space}-t-font~="p"],
p {
  font-size: $paragraph;
  font-weight: normal;

  [#{$name-space}-t-font~="lead"],
  &.lead {
    font-weight: light;
    font-size: $paragraph-lead;
  }
}

a {
  font-weight: inherit;
  text-decoration: none;
  color: inherit;

  &:active {
    font-weight: inherit;
    text-decoration: none;
    color: inherit;
  }
}

[#{$name-space}-t-font~="h1"],
h1, .h1, %h1 {
  font-size: $h1;
}

[#{$name-space}-t-font~="h2"],
h2, .h2, %h2{
  font-size: $h2;

  &[#{$name-space}-t-font~="small-caps"],
  &.small-caps {
    font-size: $h2 * .75;;
  }
}

[#{$name-space}-t-font~="h3"],
h3, .h3, %h3 {
  font-size: $h3;

  &[#{$name-space}-t-font~="small-caps"],
  &.small-caps {
    font-size: $h3 * .75;;
  }
}

[#{$name-space}-t-font~="h4"],
h4, .h4, %h4 {
  font-size: $h4;

  &[#{$name-space}-t-font~="small-caps"],
  &.small-caps {
    font-size: $h4 * .75;
  }
}

[#{$name-space}-t-font~="h5"],
h5, .h5, %h5 {
  font-size: $h5;

  &[#{$name-space}-t-font~="small-caps"],
  &.small-caps {
    font-size: $h5 * .75;
  }
}

[#{$name-space}-t-font~="h6"],
h6, .h6, %h6 {
  font-size: $h6;

  &[#{$name-space}-t-font~="small-caps"],
  &.small-caps {
    font-size: $h6 * .75;;
  }
}

[#{$name-space}-t-font~="h1"],
h1, .h1, %h1,
[#{$name-space}-t-font~="h2"],
h2, .h2, %h2,
[#{$name-space}-t-font~="h3"],
h3, .h3, %h3,
[#{$name-space}-t-font~="h4"],
h4, .h4, %h4,
[#{$name-space}-t-font~="h5"],
h5, .h5, %h5,
[#{$name-space}-t-font~="h6"],
h6, .h6, %h6 {
  font-weight: bold;
  line-height: 30px;

  &[#{$name-space}-t-font~="small-caps"],
  &.small-caps {
    font-weight: bolder;
    line-height: 20px;
    letter-spacing: 1px;
    text-transform: uppercase;
  }
}
/**
*
*  Toggle Switch
*
**/
// Only Configurable varbiable
$switch-width-sm: $base-spacing-unit*4;
$switch-width-md: $base-spacing-unit*6;
$switch-width-lg: $base-spacing-unit*8;
$switch-off-bg: $mono;
$switch-off-bg-shadow: $mono-dark;

@mixin switch-size($switch-width, $switch-container-width: ($switch-width*2) - ($base-border-width*2)) {
  height: $switch-width;
  width: $switch-container-width;

  &.#{$name-space}-switch--on {
    &:before {
      @include translate3d($switch-container-width - $switch-width, 0, 0);
    }
  }

  // Switch
  &::before {
    // Room for 2px border
    width: $switch-width - ($base-border-width*4);
    height: $switch-width - ($base-border-width*4);
    border-width: $base-border-width;
    top: $base-border-width;
    left: $base-border-width;
  }

  &.#{$name-space}-switch--circle {
    border-radius: $switch-width/2;
    &::before {
      border-radius: 50%;
    }
  }
}

@mixin switch-skin($color, $color-shadow: adjust_hue(darken($color, 10%), 7%)) {

  &.#{$name-space}-switch--on {
    background: $color;
    box-shadow: 0 0 0 $base-border-width $color-shadow;
    
    &:hover {
      background: lighten($color, 5%);
    }
  }
 
  // Switch
  &:before {
    border-color: $color-shadow;
  }
}

// Base switch styles

.#{$name-space}-switch {
  position: relative;
  display: inline-block;
  background: $switch-off-bg;
  border-color: $switch-off-bg-shadow;
  box-shadow: 0 0 0 $base-border-width $switch-off-bg-shadow;
  cursor: pointer;
  @include transition(all 0.05s ease-in-out 0.15s);
  
   // Switch
  &:before {
    content: '';
    position: absolute;
    background-color: $white;
    border-style: solid;
  }

  &.#{$name-space}-switch--on {
    @include transition(all 0.05s ease-in-out 0.15s);

    &:before {
      @include transition(all 0.15s ease-in-out);
    }
  }

  &.#{$name-space}-switch--off {
    &:before {
      border-color: $switch-off-bg-shadow;
      @include translate3d(0, 0, 0);
      @include transition(all 0.15s ease-in-out);
    }
     
    &:hover {
      background: lighten($switch-off-bg, 5%);
    }
  }
}

// Class declarations

.#{$name-space}-switch--primary {
  @include switch-skin($brand-primary, $brand-primary-shadow);
  @include switch-size($switch-width-md);
}

.#{$name-space}-switch--success {
  @include switch-skin($brand-success, $brand-success-shadow);
  @include switch-size($switch-width-md);
}

.#{$name-space}-switch--warning {
  @include switch-skin($brand-warning, $brand-warning-shadow);
  @include switch-size($switch-width-md);
}

.#{$name-space}-switch--danger {
  @include switch-skin($brand-warning-shadow);
  @include switch-size($switch-width-md);
}

.#{$name-space}-switch--sm {
  @include switch-size($switch-width-sm, $switch-width-sm*1.6);
}

.#{$name-space}-switch--md {
  @include switch-size($switch-width-md, $switch-width-md*1.6);
}

.#{$name-space}-switch--lg {
  @include switch-size($switch-width-lg, $switch-width-lg*1.6);
}

              
            
!

JS

              
                angular.module('app', [])
.controller('AppCtrl', function ($scope) {
  $scope.switch = {
    isOn: false
  };
})
.directive('vrbSwitch', function () {
  return {
    restrict: 'C',
    scope: true,
    require: 'ngModel',
    link: function (scope, ele, attr, ngModel) {
      
      ele.on('click', function () {
        ngModel.$setViewValue(!ngModel.$modelValue);
        ngModel.$render();
        scope.$apply();
      });
      
      scope.$watch(function () {
        return ngModel.$modelValue;
      }, function (newVal) {
        console.log(newVal);
        if (newVal) {
          ele.addClass('vrb-switch--on');
          ele.removeClass('vrb-switch--off');
        } else {
          ele.addClass('vrb-switch--off');
          ele.removeClass('vrb-switch--on');
        }
      })
    }
  }
});
              
            
!
999px

Console