Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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.


Auto Save

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="switch-container">
			<button id="switch" class="switch-off">OFF</button>

	<!-- Link to jquery -->
	<script src=""></script>

	<script src="js/switch.js"></script>


                /* base background colour */
body {
	background: #000;
	transition: background-color 0.50s ease 0s;
 /* switch on background colour */
.body-on {
	background: #fff;

#switch-container {
	width: 500px;
	height: 250px;
	margin-right: auto;
	margin-left: auto;
	border: none;
	/* default (off) button color */
	background: #2C3E50;
	/* set up background animation */
	transition: background-color 0.50s ease 0s;

#switch {
	height: 250px;
	width: 250px;
	border: none;
	outline: none;
	font-size: 100px;
	font-family: 'Open Sans', sans-serif;
	font-weight: 300;
	color: #ECF0F1;

	/* Set up the animation properties */
   transition: transform 0.25s linear 0s,
   		background 0.25s ease 0s,
		border-radius 0.25s ease 0s,
		box-shadow 0.25s ease 0s;

.switch-off {
	transform: translateX(0px);
	background: #E74C3C;
	border-radius: 0 50% 50% 0;
	box-shadow: 7px 0px 8px -4px rgba(0,0,0,0.54);

.switch-on {
	transform: translateX(250px);
	background: #96CA2D;
	border-radius: 50% 0 0 50%;
	box-shadow: -7px 0px 8px -4px rgba(0,0,0,0.54);

/* background colour for on */
#switch-container.background-on {
	background: #2980B9;


                $(document).ready(function() {
	// when the switch is clicked...
  function switchOff() {
    $('.switch-off').on('click', function() {
      // change off class to on
      // change the button text
      // change switch container background color to 'on';
      //change body background color
      // call the switchOn function which will fire up the event listener for the on button
  function switchOn() {
    $('.switch-on').on('click', function() {
  // when the document is ready, call the switchOff function