Pen Settings

HTML

CSS

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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

              
                - let data = [
- 	{ val: [65] }, 
- 	{ val: [12.5], max: 15, uni: .5, out: 1 }, 
- 	{ val: [4, 35], max: 50, out: 1 }
- ];
- let n = data.length;
- let char = ['c', 'a', 'b']

- for(let i = 0; i < n; i++)
	- let c = data[i], m = c.val.length;
	- let s = c.val.map((k, j) => `--${char[m - 1 + j]}: ${k}`);
	- if(c.max) { s.push(`--max: ${c.max}`) }
	- if(c.uni) { s.push(`--uni: ${c.uni}`) }
	.wrap(class=`wrap--${m}x` style=s.join('; '))
		- for(let j = 0; j < m; j++)
			- let id = `r${i}${m > 1 ? j : ''}`;
			- let ch = char[m - 1 + j]
			label.sr-only(for=id) Value #{id}
			input(type='range' id=id value=c.val[j] max=c.max step=c.uni data-c=ch)
			if(c.out)
				- s = m > 1 ? `--c: var(--${ch})` : null;
				output(for=id style=s)
              
            
!

CSS

              
                $input-w: 17.5rem;
$input-h: 1.5rem;
$input-r: .5*$input-h;
$input-p: $input-h/3;

$track-h: $input-h - 2*$input-p;
$track-r: .5*$track-h;

$thumb-d: $input-h;

$value-b: .625rem;

$t: .25s;

@mixin track($f: 0) {
	margin: $input-p;
	height: $track-h;
	border-radius: $track-r;
	box-shadow: 
		0 -1px 2px #c9c9c9, 
		0 2px 3px #e7e7e7;
	background: var(--upper, #{unquote(' ')}) 
		linear-gradient(#7b7b7b 1px, #939393 2px);
	
	@if $f > 0 {
		--upper: var(--progr-g) 0/ var(--dim) no-repeat,
	}
}

@mixin thumb() {
	box-sizing: border-box;
	border: solid var(--thumb-b, 0) transparent;
	width: var(--thumb-w);
	height: var(--thumb-h, var(--thumb-w));
	border-radius: var(--thumb-r, 4px);
	box-shadow: var(--thumb-s);
	background: var(--thumb-g, none);
	background-blend-mode: var(--mode, none);
	filter: 
		drop-shadow(0 1px #a9a9a9)
		drop-shadow(0 1px 2px #919191);
	pointer-events: auto;
	cursor: ew-resize;
}

%outer {
	border-radius: $input-r;
	box-shadow: 
		0 1px #f9f9f9, 
		inset 0 1px #c2c2c2, 
		inset 0 2px 5px #a1a1a1;
	background: linear-gradient(#b4b4b4, #f0f0f0);
}

@property --int {
	syntax: '<integer>';
	initial-value: 0;
	inherits: true
}

@property --dec {
	syntax: '<integer>';
	initial-value: 0;
	inherits: true
}

* { margin: 0; padding: 0; font: inherit }

.js { --js: 1 }
.houdini { --houdini: 1 }

.sr-only {
	position: fixed;
	right: 100%; bottom: 100%;
	opacity: 0;
	-webkit-clip-path: circle(1px);
					clip-path: circle(1px);
	user-select: none
}

body, div { display: grid }

body {
	align-content: center;
	min-height: 100vh;
	background: 
		url(https://i.imgur.com/lr3smy6.jpg) 50%
		#e9e9e9;
	background-blend-mode: multiply;
	font: 500 1em/ 1.25 ubuntu, trebuchet ms, sans-serif
}

.wrap {
	--hl: 0;
	--o: calc(var(--js, 0)*(1 - Min(1, calc(var(--uni, 0)*10))));
	--max: 100;
	align-content: end;
	place-self: center;
	margin-top: 3em;
	min-width: 8rem;
	width: calc(100% - 1.5rem); height: $input-h;
	max-width: $input-w;
	filter: Saturate(var(--hl));
	transition: filter $t ease-out;
	
	&--2x {
		@extend %outer;
		
		&::before, &::after { content: '' }
		
		&::before { @include track }
		
		&::after {
			--or: calc((1 - Max(var(--a), var(--b))/var(--max))*100%);
			--ol: calc(Min(var(--a), var(--b))/var(--max)*100%);
			display: var(--js, none);
			margin: $input-p;
			background: var(--progr-g);
			clip-path: inset(0 var(--or) 0 var(--ol) round $track-r)
		}
	}
	
	&:nth-child(1) {
		--progr-g: linear-gradient(#a8c257, #749824);
		--thumb-w: 3.5em;
		--thumb-h: 1em;
		--thumb-g: 
			repeating-linear-gradient(90deg, 
					#c0c0c0 0 1px, #ececec 0 2px, transparent 0 3px)
				50%/ 8px 65% no-repeat, 
			linear-gradient(#fefefe, #dedede), 
			repeating-conic-gradient(#e9e9e9 0% 25%, #efefef 0% 25%) 
				50%/ 2px 2px;
		--mode: normal, multiply
	}
	
	&:nth-child(2) {
		--progr-g: linear-gradient(#f4be13, #eb9605);
		--thumb-w: #{2*$input-p};
		--thumb-h: #{$track-h};
		--thumb-g: hsla(0, 0%, 80%, calc(1 - var(--js, 0)));
		--value-p: 3px .5rem;
		--value-a: 80deg;
		--value-f: .75em
	}
	
	&:nth-child(3) {
		--progr-g: linear-gradient(#96b1e0, #6e8bbb);
		--thumb-b: calc(#{$input-p} - 1px);
		--thumb-w: #{$thumb-d};
		--thumb-r: 50%;
		--thumb-s: inset 0 1px 2px #829843;
		--thumb-g: 
			linear-gradient(#afc17d, #acc469) content-box,  
			linear-gradient(#fdfdfd, #bfbfbf) border-box;
		--value-w: #{2*$value-b};
		--value-a: 90deg;
		--value-y: -.25rem
	}
	
	&::before, &::after,
	input { grid-area: calc(1 + var(--o))/ 1 }

	output { grid-area: 1/ 1 }

	&:focus-within, &:hover { --hl: 1 }
}

[type='range'] {
	&, 
	&::-webkit-slider-runnable-track, 
	&::-webkit-slider-thumb { -webkit-appearance: none }
	
	height: $input-h;
	
	&::-webkit-slider-thumb { @include thumb }
	&::-moz-range-thumb { @include thumb }
	
	&:only-of-type {
		@extend %outer;
		--k: calc(var(--c)/var(--max));
		--dim: calc(var(--js, 0)*var(--k)*100%);
		cursor: pointer;
		
		&::-webkit-slider-container {
			-webkit-user-modify: read-write !important;
			@include track(1)
		}
		
		&::-webkit-slider-runnable-track { margin: -1*$input-p }
		&::-moz-range-track { @include track(1) }
	}
	
	&:not(:only-of-type) {
		background: transparent;
		pointer-events: none
	}
	
	&, & + output {
		--sel: 0;
		z-index: calc(1 + var(--sel))
	}
	
	+ output {
		--int: Max(0, calc(var(--c) - .5));
		--dec: calc((var(--c) - var(--int))*10);
		--pos: calc(.5*var(--thumb-w) + 
								var(--c)/var(--max)*(100% - var(--thumb-w)));
		display: var(--js, none);
		justify-self: start;
		margin-left: var(--pos);
		transform: translate(-50%, var(--value-y, #{.5*$input-p}));
		filter: 
			drop-shadow(0 1px #b1b1b1)
			drop-shadow(1px 1px 2px #a8a8a8);
		counter-reset: int var(--int) dec var(--dec);
		
		&::after {
			display: grid;
			place-content: center;
			border: solid $value-b transparent;
			padding: var(--value-p);
			width: var(--value-w);
			border-radius: calc(#{$value-b} + 4px);
			transform-origin: 50% 100%;
			transform: scale(var(--hl));
			background: linear-gradient(#f8f8f8, #c8c8c8) border-box;
			color: #625d5d;
			text-shadow: 1px 1px #fbfbfb;
			font-size: var(--value-f);
			--mask: 
				linear-gradient(red, red) padding-box, 
				conic-gradient(from calc(-.5*var(--value-a)) at 50% 100%, 
						red 0% var(--value-a), transparent 0%) 
					50% 100%/ 50% 50% no-repeat;
			-webkit-mask: var(--mask);
							mask: var(--mask);
			transition: transform $t ease-out;
			content: counter(int)
		}
	}
	
	&[step] + output {
		display: var(--houdini, none);
		
		&::after {
			content: counter(int) '.' counter(dec)
		}
	}
	
	&:focus { outline: none }
	
	&:focus, &:hover { &, & + output { --sel: 1 } }
}
              
            
!

JS

              
                /* external resources *only* for displaying the info boxes */

/* this below is all the JS needed for the demo itself to work */
document.documentElement.classList.add('js');
if(CSS.registerProperty)
	document.documentElement.classList.add('houdini');

addEventListener('input', e => {
	let _t = e.target;
	
	_t.parentNode.style.setProperty(`--${_t.dataset.c}`, +_t.value)
}, false);
              
            
!
999px

Console