Pen Settings



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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


Babel includes JSX processing.

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


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


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.


                <div id="app">
  <switch-button v-model="switch1">Lorem ipsum dolor sit amet</switch-button>
  <switch-button v-model="switch2" color="#F5BF21">I agree to Terms and Conditions</switch-button>
  <switch-button v-model="switch3" color="#253DB9">I want to be spammed to death</switch-button>
  <switch-button v-model="switch4" color="#F53731">I agree to give my soul to the Devil<br><small>(a transfert fee may apply)</small></switch-button>

  <div class="bottom-message">
    <span v-if="!(switch1 && switch2 && switch3 && switch4)">Please say yes to everything before proceeding</span>
    <span v-else>Thank you!</span>

<template id="switch-button">
  <div class="switch-button-control">
    <div class="switch-button" :class="{ enabled: isEnabled }" @click="toggle" :style="{'--color': color}">
      <div class="button"></div>
    <div class="switch-button-label">


                // For pen only
#app {
  font-family: Lato, sans-serif;
  .switch-button {
    margin: 10px 0;
  .bottom-message {
    margin-top: 20px;
    font-size: 125%;

// For switch-button styling
.switch-button-control {
  display: flex;
  flex-direction: row;
  align-items: center;
  .switch-button {
    $switch-button-height: 1.6em;
    $switch-button-color: var(--color);
    $switch-button-border-thickness: 2px;
    $switch-transition: all 0.3s ease-in-out;
    $switch-is-rounded: true;

    height: $switch-button-height;
    width: calc(#{$switch-button-height} * 2);
    border: $switch-button-border-thickness solid $switch-button-color;
    box-shadow: inset 0px 0px $switch-button-border-thickness 0px
      rgba(0, 0, 0, 0.33);
    border-radius: if($switch-is-rounded, $switch-button-height, 0);

    transition: $switch-transition;

    $button-side-length: calc(
      #{$switch-button-height} - (2 * #{$switch-button-border-thickness})
    cursor: pointer;

    .button {
      height: $button-side-length;
      width: $button-side-length;
      border: $switch-button-border-thickness solid $switch-button-color;
      border-radius: if($switch-is-rounded, $button-side-length, 0);
      background: $switch-button-color;

      transition: $switch-transition;

    &.enabled {
      background-color: $switch-button-color;
      box-shadow: none;

      .button {
        background: white;
        transform: translateX(
          calc(#{$button-side-length} + (2 *#{$switch-button-border-thickness}))

  .switch-button-label {
    margin-left: 10px;



                Vue.component("switch-button", {
  template: "#switch-button",
  model: {
    prop: "isEnabled",
    event: "toggle"
  props: {
    isEnabled: Boolean,
    color: {
      type: String,
      required: false,
      default: "#4D4D4D"
  methods: {
    toggle: function() {
      this.$emit("toggle", !this.isEnabled);

new Vue({
  el: "#app",
  data: function() {
    return {
      switch1: true,
      switch2: false,
      switch3: false,
      switch4: false