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 t = .5;

form
	input#o0(type='radio' name='o' value=0 checked)
	label(for='o0' style='--idx: 0') swollen
	input#o1(type='radio' name='o' value=1)
	label(for='o1' style='--idx: 1') squished

svg(viewBox='-150 -100 265 200')
	filter#b
		feComponentTransfer
			feFuncR(type="linear" slope=t)
			feFuncG(type="linear" slope=t)
			feFuncB(type="linear" slope=t)
	g#orig
		path.arr(d=`M0,-95 v190 m-2,-5 2,1 2,-1 -2,5z
								M-110,0 h220 m-5,2 1,-2 -1,-2 5,2z`)
		circle(r=1.5)
		text(x=105 y=8) x
		text(x=3 y=95) y
	path#bbox.ani(d='M-50,-50q-25,50 0 100h100v-100')
	g.trig(data-comp='3')
		path.arr(d=`M50,50 v-100 m2,5 -2,-1 -2,1 2,-5z`)
		circle(cx=50 cy=-50 r=2)
		g.lbl.ani(style=`--pos: translate(51px, 0)`)
			rect(y=-8 width=42 height=16 rx=2)
			text(x=1 y=3) dy: -100
	g.trig(data-comp='2')
		path.arr(d=`M-50,50 h100 m-5,2 1,-2 -1,-2 5,2z`)
		circle(cx=50 cy=50 r=2)
		g.lbl.ani(style=`--pos: translate(0, 51px)`)
			rect(x=-18 width=36 height=16 rx=2)
			text(y=11 text-anchor='middle') dx: 100
	g.trig(data-comp='1')
		path.help.ani(d=`M-50,-50 l-25,50 M-50,50 l-25,-50`)
		path.quad.ani(d=`M-50,-50 q-25,50 0,100`)
		g.trig(data-comp='1.0')
			marker#m1(viewBox='-6 -3 6 6' orient='auto' markerWidth='7.5' markerHeight='7.5')
				path(d=`M-5-2 l5 2 -5 2 1-2z`)
			path.arr.ani(d=`M-50,-50 l-25,50` marker-end='url(#m1)')
			circle.cx.ani(cx=-75 r=2)
			g.lbl.lbl--mov.ani(style=`--pos0: translate(-78px, 0); --pos1: translate(-22px, 0); --pos: var(--pos0)`)
				rect(x=-72 y=-8 width=72 height=16 rx=2 data-x='-72')
				text(x=-36 y=3 text-anchor='middle') dx: <tspan class='lbl__cx'>-25</tspan>, dy: 50
		g.trig(data-comp='1.1')
			path.arr.ani(d=`M-50,-50 v100 m-2,-5 2,1 2,-1 -2,5z`)
			circle(cx=-50 cy=50 r=2)
			g.lbl.ani(style=`--pos: translate(-53px, 51px)`)
				rect(x=-65 y=-2 width=65 height=16 rx=2)
				text(x=-1 y=9 text-anchor='end') dx:0, dy: 100
	g.trig(data-comp='0')
		circle(cx=-50 cy=-50 r=2)
		g.lbl.ani(style=`--pos: translate(-53px, -50px)`)
			rect(x=-39 y=-15 width=39 height=16 rx=2)
			text(x=-1 y=-4 text-anchor='end') -50,-50

pre
	span.token--prop d
	span.token--punc :
	|  
	span.token--val
		span.token--func path
		span.token--punc (
		span.token--arg
			span.token--str '
				span.token--cmd.trig.ani(data-comp='0')
					span.token--cname M
					span.token--coord -50,-50
				span.token--cmd.trig.ani(data-comp='1')
					span.token--cname q
					span.token--coord.trig.ani(data-comp='1.0')
						span.token--cx -25
						| ,
						span.token--cy 50
					|  
					span.token--coord.trig.ani(data-comp='1.1') 0,100
				span.token--cmd.trig.ani(data-comp='2')
					span.token--cname h
					span.token--dist 100
				span.token--cmd.trig.ani(data-comp='3')
					span.token--cname v
					span.token--dist -100
				| '
		span.token--punc )
              
            
!

CSS

              
                $d: 1em;
$c: #ff8a00 (#f44336 #e52e71) /*#9c27b0*/ #03a9f4 /*#4caf50*/ #8bc34a;
$n: length($c);
$t: .3s;

* { margin: 0; font: inherit }

body {
	--o: 0;
	--c: #efefef;
	display: grid;
	grid-template-rows: max-content 1fr max-content;
	height: 100vh;
	font: 6.5vw/ 1.375 ubuntu mono, consolas, monaco, monospace;
	
	@media (min-width: 480px) { font-size: 2rem }
}

form, pre {
	overflow-x: hidden;
	padding: .125em .25em;
	background: #100e17;
	color: #fff
}

form {
	display: grid;
	grid-auto-flow: row dense;
	grid-template-columns: max-content repeat(2, $d) max-content;
	place-content: center;
	
	&::before, &::after {
		z-index: 0;
		grid-column: 2;
		grid-row: 1;
		align-self: center;
		height: $d;
		border-radius: $d;
		content: ''
	}
	
	&::before {
		grid-column-end: span 2;
		box-shadow: 0 0 0 2px currentcolor
	}
	
	&::after {
		box-sizing: border-box;
		padding: .125em;
		transform: translate(calc(var(--o)*100%));
		background: crimson content-box;
		transition: $t ease-out
	}
}

[type='radio'] {
	position: absolute;
	right: 100vw;
	clip-path: inset(50%);
	
	+ label {
		position: relative;
		z-index: 2;
		padding: 0 .25em;
		cursor: pointer;
		
		&::before {
			position: absolute;
			top: calc(50%	- #{.5*$d});
			right: calc(var(--idx)*100% - (1 - var(--idx))*#{$d});
			width: $d; height: $d;
			content: ''
		}
	}
}

svg {
	--c: currentcolor;
	place-self: center;
	max-width: 640px;
	color: #aaa;
	font-size: 10px;
	word-spacing: -4px
}

rect, circle { fill: var(--c) }

circle { stroke: #333; stroke-width: .5 }

marker path { fill: var(--c) }

.ani { transition: $t ease-out }

.arr {
	fill: var(--c);
	stroke: var(--c);
	stroke-miterlimit: 6;
	filter: url(#b);
	
	.trig.hl & { opacity: 1 }
}

[id='orig'] {
	color: var(--c);
	font-family: times new roman, serif;
	font-style: italic;
	
	text { fill: currentcolor }
}

[id='bbox'] {
	fill: darkorange;
	opacity: .2
}

.help {
	fill-opacity: .001;
	stroke-opacity: .25;
	stroke: currentcolor;
	stroke-width: .5px;
	
	.hl & { stroke-opacity: 1 }
}

.trig { cursor: pointer }

@for $i from 0 to $n {
	[data-comp='#{$i}'] {
		$cc: nth($c, $i + 1);
		
		@if length($cc) > 1 {
			$m: length($cc);
			
			--c: #{mix(#fff, mix($cc...), 35%)};
			
			@for $j from 0 to $m {
				@at-root {
					[data-comp='#{$i}.#{$j}'] { --c: #{mix(#fff, nth($cc, $j + 1), 35%)} }
				}
			}
		}
		@else { --c: #{mix(#fff, $cc, 35%)} }
	}
}

.quad {
	fill: none;
	stroke: var(--c);
	
	.hl & { stroke-width: 2px }
	
	~ g .arr { opacity: .001 }
}

.lbl {
	transform: var(--pos) scale(0);
	
	.hl & { transform: var(--pos) }
}

pre {
	padding-left: calc(9ch + .25em);
	text-indent: -9ch;
	white-space: pre-wrap;
	
	span { text-indent: 0px }
}

span.trig {
	display: inline-block;
	padding: 0 .125em;
	border-radius: 5px;
	color: var(--c);
	transition-property: background, color;
	
	&.hl {
		background: var(--c);
		color: #101010;
		
		.trig { color: inherit }
	}
}
              
            
!

JS

              
                const _BBOX = document.getElementById('bbox'), 
			_C_CX = [...document.querySelectorAll('.token--cx')], 
			_V_CX = [...document.querySelectorAll('.cx')], 
			_L_CX = [...document.querySelectorAll('.lbl__cx')], 
			_STR = document.querySelector('.token--str'), 
			_HELP = [...document.querySelectorAll('.help')], 
			_QUAD = [...document.querySelectorAll('.quad')], 
			_MOV = [...document.querySelectorAll('.lbl--mov')], 
			_RECT = [...document.querySelectorAll('.lbl--mov rect')], 
			_TEXT = [...document.querySelectorAll('.lbl--mov text')], 
			_ARR = [...document.querySelectorAll('.arr.ani')];

let hl = null, o = 0, cx = [];

function trigger(_el) {
	if(_el.classList.contains('trig')) return _el;
	else {
		if(_el !== document.body) return trigger(_el.parentNode);
		return null;
	}
};

addEventListener('mouseover', e => {
	let _t = trigger(e.target);
	
	if(_t) {
		let comp = _t.dataset.comp;
		
		hl = [...document.querySelectorAll(`[data-comp='${comp}']`)];
		hl.forEach(c => c.classList.add('hl'))
	}
}, false);

addEventListener('mouseout', e => {
	let _t = trigger(e.target);
	
	if(_t) {
		hl.forEach(c => c.classList.remove('hl'))
	}
}, false);

addEventListener('change', e => {
	o = +e.target.value;
	
	document.body.style.setProperty('--o', o);
	_C_CX.forEach((c, i) => {
		let sgn = Math.pow(-1, o + i + 1);
		_L_CX[i].textContent = c.textContent = cx[i] = sgn*Math.abs(+c.textContent);
		_BBOX.setAttribute('d', _STR.textContent.replace(/\'/g, ''));
		_HELP[i].setAttribute('d', _HELP[i].getAttribute('d').replace(/\l\-?\d+\,/gi, `l${cx[i]},`));
		_ARR[i].setAttribute('d', _ARR[i].getAttribute('d').replace(/\l\-?\d+\,/gi, `l${cx[i]},`));
		_QUAD[i].setAttribute('d', _QUAD[i].getAttribute('d').replace(/\q\-?\d+\,/i, `q${cx[i]},`));
		_V_CX[i].setAttribute('cx', +_V_CX[i].getAttribute('cx') + 2*cx[i]);
		_MOV[i].style.setProperty('--pos', `var(--pos${o})`);
		_TEXT[i].setAttribute('x', sgn*Math.abs(+_TEXT[i].getAttribute('x')));
		_RECT[i].setAttribute('x', (1 - (o - i))*+_RECT[i].dataset.x);
		
	});
}, false);
              
            
!
999px

Console