Pen Settings

HTML

CSS

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

JavaScript

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

Packages

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.

Behavior

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.

HTML

              
                <input class="pristine" type="checkbox" name="toggle" value="on">
              
            
!

CSS

              
                * {
	border: 0;
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}
body, input {
	font: 80px/1.5 sans-serif;
}
body, input[type=checkbox]:before {
	background-image:
		linear-gradient(90deg,#f1f2f3 2px,#f1f2f300 2px),
		linear-gradient(#f1f2f3 2px,#fff 2px);
	background-repeat: repeat;
	background-size: 0.75em 0.375em;
}
body {
	background-position: 50% calc(50% + 0.2em);
	display: grid;
	place-items: center;
	height: 100vh;
}
input[type=checkbox] {
	--off: #c7cad1;
	--mid: #829ad6;
	--on: #255ff4;
	--transDur: 0.5s;
	--timing: cubic-bezier(0.6,0,0.4,1);
	animation: bgOff var(--transDur) var(--timing);
	background-color: var(--off);
	border-radius: 0.67em / 0.5em;
	box-shadow:
		0 0.05em 0.1em #00000007 inset,
		0 -0.25em 0.25em #0001 inset,
		0 -0.5em 0 #0001 inset,
		0 0.1em 0.1em #0001;
	cursor: pointer;
	position: relative;
	width: 2.25em;
	height: 1.5em;
	-webkit-appearance: none;
	appearance: none;
	-webkit-tap-highlight-color: transparent;
}
input[type=checkbox]:before {
	animation: handleOff var(--transDur) var(--timing);
	background-attachment: fixed;
	background-position: 50% calc(50% - 0.1875em);
	border-radius: 0.5em / 0.375em;
	box-shadow:
		0 0.175em 0.175em 0 #0001 inset,
		0 0.375em 0 #0002 inset,
		0 0.375em 0 var(--off) inset,
		0 0.475em 0.1em #0001 inset;
	content: "";
	display: block;
	position: absolute;
	top: 0.125em;
	left: 0.125em;
	width: 1em;
	height: 0.75em;
}
input[type=checkbox]:checked {
	animation: bgOn var(--transDur) var(--timing) forwards;
}
input[type=checkbox]:checked:before {
	animation: handleOn var(--transDur) var(--timing) forwards;
}
input[type=checkbox]:focus {
	outline: none;
}
input[type=checkbox].pristine, input[type=checkbox].pristine:before {
	animation: none;
}
/* Dark mode */
@media (prefers-color-scheme: dark) {
	body, input[type=checkbox]:before {
		background-image:
			linear-gradient(90deg,#3a3d46 2px,#3a3d4600 2px),
			linear-gradient(#3a3d46 2px,#2e3138 2px);
	}
	input[type=checkbox] {
		--off: #5c6270;
		--mid: #3d5fb6;
	}
}
/* Animations */
@keyframes bgOff {
	from {
		background-color: var(--on);
	}
	50% {
		background-color: var(--mid);
	}
	to {
		background-color: var(--off);
	}
}
@keyframes bgOn {
	from {
		background-color: var(--off);
	}
	50% {
		background-color: var(--mid);
	}
	to {
		background-color: var(--on);
	}
}
@keyframes handleOff {
	from {
		box-shadow:
			0 0.175em 0.175em 0 #0001 inset,
			0 0.375em 0 #0002 inset,
			0 0.375em 0 var(--on) inset,
			0 0.475em 0.1em #0001 inset;
		left: 1.125em;
		width: 1em;
	}
	50% {
		box-shadow:
			0 0.175em 0.175em 0 #0001 inset,
			0 0.375em 0 #0002 inset,
			0 0.375em 0 var(--mid) inset,
			0 0.475em 0.1em #0001 inset;
		left: 0.125em;
		width: 2em;
	}
	to {
		box-shadow:
			0 0.175em 0.175em 0 #0001 inset,
			0 0.375em 0 #0002 inset,
			0 0.375em 0 var(--off) inset,
			0 0.475em 0.1em #0001 inset;
		left: 0.125em;
		width: 1em;
	}
}
@keyframes handleOn {
	from {
		box-shadow:
			0 0.175em 0.175em 0 #0001 inset,
			0 0.375em 0 #0002 inset,
			0 0.375em 0 var(--off) inset,
			0 0.475em 0.1em #0001 inset;
		left: 0.125em;
		width: 1em;
	}
	50% {
		box-shadow:
			0 0.175em 0.175em 0 #0001 inset,
			0 0.375em 0 #0002 inset,
			0 0.375em 0 var(--mid) inset,
			0 0.475em 0.1em #0001 inset;
		left: 0.125em;
		width: 2em;
	}
	to {
		box-shadow:
			0 0.175em 0.175em 0 #0001 inset,
			0 0.375em 0 #0002 inset,
			0 0.375em 0 var(--on) inset,
			0 0.475em 0.1em #0001 inset;
		left: 1.125em;
		width: 1em;
	}
}
              
            
!

JS

              
                // for removing the `pristine` class that prevents CSS animation on load
document.addEventListener("click",e => {
	let tar = e.target;
	if (tar.name == "toggle")
		tar.removeAttribute("class");
});
              
            
!
999px

Console