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

              
                - let data = [
- 	{ val: 69, col: ['#47b784', '#4b569f'] }, 
- 	{ val: 59, col: ['#ede54e', '#e7574e'] }, 
- 	{ val: 51, col: ['#4a569b', '#4ad685'] }, 
- 	{ val: 83, col: ['#d6dc26', '#1e9d49'] }, 
- 	{ val: 36, col: ['#505050', '#7f7f7f'] }
- ];
- let n = data.length;
- let min = _min || 0;
- let max = _max || _max === 0 ? _max : 100;
- let val;

body(style=`--min: ${min}; --max: ${max}`)
	- for(let i = 0; i < n; i++)
		- let r = data[i];
		- val = r.val || r.val === 0 ? r.val : .5*(min + max);
		- let s = [`--val: ${val}`];
		- if(r.col) s.push(...r.col.map((c, j) => `--c${j}: ${c}`));
		- s = s.join('; ')
		input(type='range' min=_min value=val max=_max style=s)
              
            
!

CSS

              
                @use 'sass:math';

$input-b: .625em;
$input-p: .375em;
$input-o: $input-b + $input-p;

$track-w: 41em;
$track-h: 1.5em;
$track-r: .5*$track-h;

$round-r: $track-h/3;

$va: 180deg/3;
$ha: .5*$va;
$sin: math.sin($ha);
$cos: math.cos($ha);
$tan: math.tan($ha);

$thumb-h0: 4*$round-r;
$thumb-u0: 3*$input-p;
$thumb-r0: 1.25*$thumb-h0;

$thumb-d2: 6*$round-r;
$thumb-r2: .5*$thumb-d2;
$thumb-h2: $thumb-r2*(1 + $sin);
$thumb-c2: .5*$round-r;
$thumb-y2: $thumb-c2/$sin;
$thumb-v2: $thumb-c2/$tan;
$thumb-s2:
	$thumb-r2*(1 - $cos) + $thumb-v2 
	$thumb-c2*($sin + 1);
$thumb-p2: $thumb-h2 - nth($thumb-s2, 2);

$thumb-d4: 5*$round-r;

$d: $track-h;
$s: 2*$input-o;

@mixin track() {
	border: solid $input-b transparent;
	padding: $input-p;
	width: var(--track-w);
	height: $track-h;
	border-radius: $track-r + $input-o;
	box-shadow: 
		0 .25*$track-h .5*$track-h #b0b0b0,
		-.25*$track-h .5*$track-h 1px hsla(0, 0%, 100%, .1), 
		inset 0 -1px 1px #b9b9b9, 
		inset 0 -3px #e4e4e4;
	background: 
		linear-gradient(90deg, var(--c0), 
				var(--c1) calc(100% + var(--_js)*var(--thumb-x))) 
			0/ calc(var(--_js)*var(--progr-w)) 100%
			no-repeat content-box, 
		var(--input-g) padding-box, 
		linear-gradient(#d1d1d1, #f5f5f5) border-box
}

@mixin thumb($prf: '') {
	box-sizing: border-box;
	border: solid var(--thumb-b, 0) transparent;
	width: var(--thumb-w);
	height: var(--thumb-h);
	border-radius: var(--thumb-a, var(--thumb-r));
	transform: var(--thumb-t);
	box-shadow: var(--thumb-s);
	background: 
		var(--thumb-g, 
			var(--thumb-i, 
				radial-gradient(circle #{$round-r} 
						at calc(100% - var(--thumb-x)), 
						var(--c1) calc(100% - 1px), 
						transparent)) padding-box, 
			var(--thumb-o, 
				linear-gradient(#f2f2f2, #939393)) 
					border-box);
	background-blend-mode: var(--thumb-z);
	clip-path: var(--thumb-c);
	filter: var(--thumb-f);
	#{$prf}mask: var(--thumb-m);
	#{$prf}mask-repeat: no-repeat;
	#{$prf}mask-composite: 
		var(--thumb-c#{if($prf == '', 's', 'w')}, exclude);
	cursor: ew-resize
}

* { margin: 0; font: inherit }

html, body { display: grid }

html {
	height: 100%;
	background: 
		radial-gradient(#f1edea 1px, transparent 3px) 
			50%/ #{$d $d}, 
		radial-gradient(circle, #eee 20%, #a1a1a1);
	background-blend-mode: screen
}

.js { --js: 1 }

body {
	--_js: var(--js, 0);
	--not-js: calc(1 - var(--_js));
	grid-gap: $s;
	place-content: center;
}

[type='range'] {
	&, 
	&::-webkit-slider-runnable-track, 
	&::-webkit-slider-thumb { -webkit-appearance: none }
	
	--ratio: 
		calc((var(--val) - var(--min))/(var(--max) - var(--min)));
	--track-w: min(#{$track-w}, 100vw - 20px);	
	--thumb-h: #{$track-h};
	--thumb-w: var(--thumb-h);
	--thumb-r: calc(.5*var(--thumb-h));
	--thumb-x: var(--thumb-r);
	--mover-o: calc(#{$track-r} + -1*var(--thumb-r));
	--mover-w: 
		calc(var(--track-w) - 2*var(--mover-o) - var(--thumb-w));
	--progr-s: 
		calc(var(--thumb-w) + var(--mover-o) - var(--thumb-x));
	--progr-w: calc(var(--progr-s) + var(--ratio)*var(--mover-w));
	--input-g: linear-gradient(#b7b7b7, #dcdcdc);
	--thumb-cw: xor;
	place-self: center;
	@include track;
	filter: sepia(calc(1 - var(--sel, 0)));
	
	@supports selector(::-moz-range-thumb) {
		border: none;
		padding: 0;
		width: calc(var(--track-w) - 2*var(--mover-o));
		height: $track-h + 2*$input-o;
		box-shadow: none;
		background: none
	}
	
	&:nth-child(odd):nth-child(-n + 3) { --thumb-a: 0 }
	
	&:nth-child(3n + 1) {
		--thumb-h: #{$thumb-h0};
		--thumb-w: 
			calc(var(--thumb-h) + 2*#{$thumb-u0} + var(--thumb-x));
		--thumb-l: 
			linear-gradient(90deg, transparent var(--thumb-r), red 0), 
			repeating-linear-gradient(90deg, 
				transparent 0 #{.5*$thumb-u0}, 
				red 0 #{$thumb-u0}) var(--thumb-r)/ #{2*$thumb-u0} 100%;
		--thumb-m: var(--thumb-l)
	}
	
	&:nth-child(1) {
		--slist: 
			red calc(100% - .5px), 
			transparent calc(100% + .5px);
		--thumb-x: var(--thumb-h);
		--thumb-m: 
			var(--thumb-l), 
			radial-gradient(circle #{$thumb-r0} 
					at 0 #{$thumb-r0}, 
					var(--slist)) 100%/ var(--thumb-x) 100%, 
			radial-gradient(circle #{$thumb-r0} 
					at 0 calc(100% - #{$thumb-r0}), 
					var(--slist)) 100%/ var(--thumb-x) 100%
	}
	
	&:nth-child(2) {
		--thumb-b: calc(var(--thumb-r) - #{.875*$round-r});
		--thumb-s: inset 1px 1px 3px #8f8f8f;
		--thumb-i: 
			var(--input-g) 0/ 100% #{$track-h + 2*$input-p};
		--thumb-o: 
			linear-gradient(90deg, var(--c0), var(--c1)) 100%/ 
				calc(var(--_js)*(var(--progr-w) + var(--thumb-x)) + 
						 var(--not-js)*100%)
	}
	
	&:nth-child(3) {
		--thumb-h: #{$thumb-d2};
		--thumb-t: 
			translatey(calc(.25*var(--thumb-r) - .5*#{$thumb-c2}));
		--thumb-g:
			linear-gradient(
				hsla(0, 0%, 65%, .5), 
				hsla(0, 0%, 85%, .5)), 
			conic-gradient(from #{180deg - $ha} 
					at 50% #{$thumb-y2}, 
					#fff #{$va}, transparent 0%) 
				0 0/ 100% #{$thumb-h2 - $thumb-c2}, 
			linear-gradient(#fff, #000);
		--thumb-z: normal, difference;
		--thumb-c: 
			polygon(50% 0, 
							#{50%*(1 - $cos)} #{50%*(1 + $sin)}, 
							#{50%*(1 + $cos)} #{50%*(1 + $sin)});
		--thumb-f: blur(1px) contrast(2) contrast(.8);
		--slist: 
			transparent calc(100% - .5px), 
			red calc(100% + .5px);
		--thumb-m: 
			linear-gradient(red, red), 
			radial-gradient(circle #{$thumb-c2} 
					at 50% #{$thumb-y2}, var(--slist)) 
				0 0/ 100% #{$thumb-v2*$cos},
			radial-gradient(circle #{$thumb-c2} 
					at 100% #{$thumb-c2*$sin}, var(--slist)) 
				0 #{$thumb-p2}/ #{$thumb-s2}, 
			radial-gradient(circle #{$thumb-c2} 
					at 0 #{$thumb-c2*$sin}, var(--slist)) 
				100% #{$thumb-p2}/ #{$thumb-s2}
	}
	
	&:nth-child(5) {
		--thumb-h: #{$thumb-d4};
		--thumb-g: 
			radial-gradient(closest-side, 
					var(--c1) #{$round-r}, 
					#f3f3f3 calc(#{$round-r} + 1px) 70%, 
					#b2b2b2)
	}
	
	&::-webkit-slider-runnable-track { margin: var(--mover-o) }
	&::-moz-range-track { @include track }
	
	&::-webkit-slider-thumb { @include thumb('-webkit-') }
	&::-moz-range-thumb { @include thumb }
	
	&:focus { outline: none }
	&:hover, &:focus { --sel: 1 }
}
              
            
!

JS

              
                document.documentElement.classList.add('js');

addEventListener('input', e => {
	let _t = e.target;
	
	_t.style.setProperty('--val', +_t.value)
})
              
            
!
999px

Console