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

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

              
                - var colors = [{value:"brown",name:"Brown"},{value:"red",name:"Red"},{value:"orange",name:"Orange"},{value:"yellow",name:"Yellow"},{value:"green",name:"Green"},{value:"lime",name:"Lime"},{value:"cyan",name:"Cyan"},{value:"lightblue",name:"Light Blue"},{value:"blue",name:"Blue"},{value:"purple",name:"Purple"},{value:"magenta",name:"Magenta"},{value:"pink",name:"Pink"},{value:"black",name:"Black"},{value:"gray",name:"Gray"},{value:"lightgray",name:"Light Gray"},{value:"white",name:"White"}];

.cp
	each color, index in colors
		label(class="cp__color cp__color--" + color.value)
			input.cp__color-input(type="radio",name="color",value=color.value,title=color.name,checked=index===0)
			span.cp__sr-only=color.name
              
            
!

CSS

              
                $hue: 223
$colors: ("brown": hsl(23,90%,25%),"red": hsl(3,90%,55%),"orange": hsl(33,90%,55%),"yellow": hsl(53,90%,55%),"green": hsl(78,90%,30%),"lime": hsl(88,90%,55%),"cyan": hsl(183,90%,55%),"lightblue": hsl(198,90%,55%),"blue": hsl(223,90%,55%),"purple": hsl(273,90%,45%),"magenta": hsl(303,90%,55%),"pink": hsl(343,90%,75%),"black": hsl(0,0%,10%),"gray": hsl(0,0%,30%),"lightgray": hsl(0,0%,60%),"white": hsl(0,0%,90%))

*
	border: 0
	box-sizing: border-box
	margin: 0
	padding: 0

\:root
	font-size: calc(12px + (32 - 12) * (100vw - 320px) / (1280 - 320))

body,
input
	font: 1em/1.5 sans-serif

body
	background: linear-gradient(-45deg,#{hsl($hue,10%,90%)},#{hsl($hue,10%,80%)})
	height: 100vh
	min-height: 600px
	display: grid
	overflow-x: hidden
	place-items: center

.cp
	background: linear-gradient(90deg,#{hsl($hue,10%,45%)},#{hsl($hue,10%,65%)})
	border-radius: 2em
	box-shadow: 0.1em 0.1em 0 #{hsl($hue,10%,75%)}, 0.25em 0.25em 0 #{hsl($hue,10%,45%)}, 0.375em 0.375em 0.375em #{hsla($hue,0%,0%,0.6)}
	display: grid
	grid-template-columns: repeat(4,1fr)
	grid-template-rows: repeat(4,1fr)
	width: 16em
	height: 16em
	transform: rotateX(45deg) rotateZ(45deg)

	&__color
		padding: 0.5em
		-webkit-tap-highlight-color: transparent
		&,
		&-input
			display: block
		&-input
			border-radius: 50%
			position: relative
			width: 3em
			height: 3em
			transform: translate3d(-0.5em,-0.5em,0)
				style: preserve-3d
			transition: transform 0.15s linear
			-webkit-appearance: none
			appearance: none
			&:after
				border-radius: inherit
				content: ""
				display: block
				position: absolute
				inset: 0
				transform: translate3d(0.25em,0.25em,-1px)
				transition: box-shadow 0.15s linear
			&:checked
				transform: translate3d(-0.25em,-0.25em,0)
			&:focus
				outline: transparent

		@each $name, $value in $colors
			&--#{$name} &-input
				background-image: linear-gradient(90deg,$value,lighten($value,15%))
				&:after
					background: linear-gradient(0deg,darken($value,10%),darken($value,30%),darken($value,20%))
					box-shadow: 0.25em 0.25em 0.25em hsla(0,0%,0%,0.9), 0.5em 0.5em 0.5em fade-out($value,0.4)
				&:checked
					&:after
						box-shadow: 0 0 0.125em hsla(0,0%,0%,0.9), 0.25em 0.25em 0.25em fade-out($value,0.4)
	&__sr-only
		clip: rect(1px,1px,1px,1px)
		overflow: hidden
		position: absolute
		width: 1px
		height: 1px

/* Dark theme */
@media (prefers-color-scheme: dark)
	body
		background: linear-gradient(-45deg,#{hsl($hue,10%,20%)},#{hsl($hue,10%,10%)})
	.cp
		background: linear-gradient(90deg,#{hsl($hue,10%,20%)},#{hsl($hue,10%,40%)})
		box-shadow: 0.1em 0.1em 0 #{hsl($hue,10%,50%)}, 0.25em 0.25em 0 #{hsl($hue,10%,20%)}, 0.375em 0.375em 0.375em #{hsla($hue,0%,0%,0.6)}
              
            
!

JS

              
                
              
            
!
999px

Console