Pen Settings



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


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


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.


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.


                <ground-control control-for=".major-tom" set-prop="--scale">
	<label for="font-scale">Font scale</label>
	<input id="font-scale" type="range" min="0" max="3" step="0.1" value="1" />

<ground-control control-for=".major-tom" set-attr="color-mode">
	<label for="color-mode">Color Mode</label>
	<select id="color-mode">
		<option value="light">light</option>
		<option value="dark">dark</option>
		<option value="rainbow">rainbow</option>
	<button reset-for="color-mode">reset</button>

<ground-control control-for="div" set-prop="border">
	<label for="border">Border</label>
	<input id="border" type="text" value="medium solid teal">

<button id="reset-all">Reset all</button>

<div class="major-tom">
			Scale: <output for="font-scale" with-units="vw">N/A</output>
			Mode: <output for="color-mode">N/A</output>
		This web component is based on
		Eric Meyer's
		<a href=""><code>super-slider</code> component</a>
		and excellent article
		<a href="">
			<em>Blinded By the Light DOM</em></a>.
		My goal was to make it a bit more generic,
		for any <code>input</code> to control
		the properties or attributes
		on any number of target elements.
		It also finds any related <code>ouptut</code> elements,
		and keeps them up to date with changes.
		This experiment keeps escalating,
		as Eric and I continue to fork our forks of forks,
		<a href="">borrowing and sharing ideas</a>,
		and learning as we go.
		<em>I am not a web component expert</em>,
		and may be doing it all wrong.



	The styles are just to visualize results,
	they are not part of the component.

* { box-sizing: border-box; }
html { font-family: sans-serif; }

ground-control {
	display: block;
	margin-block: 1em;

label {
	display: block;
	font-weight: bold;

.major-tom {
	font-size: calc(1em + (1vw * var(--scale)));
	margin-block: 1em;

output {
	font-family: monospace;
	background: linear-gradient(
		transparent 0 50%, 
		var(--output-highlight, papayawhip) 50% 100%
	padding-inline: 0.5em;

[color-mode] {
	background: var(--bg, white);
	border: thin solid;
	color: var(--text, black);
	padding: 1em;
	& a:any-link {
		color: var(--link, blue);

[color-mode='dark'] {
	--bg: black;
	--text: white;
	--link: cyan;
	--output-highlight: mediumvioletred;

[color-mode='rainbow'] {
	linear-gradient(hsl(0deg 0% 100% / 0.9), hsl(0deg 0% 100% / 0.9)),
	linear-gradient(to bottom right,
		maroon 0 12%,
		orange 12% 24%,
		yellow 24% 36%,
		teal 36% 48%,
		midnightblue 48% 60%,
		indigo 60% 72%,
		darkmagenta 72% 84%,
		mediumvioletred 84%
	--output-highlight: cyan;
	--link: mediumvioletred;
	text-shadow: 0 1px 0 white;
	background-size: calc(100% - 1em) calc(100% - 1em), 100% 100%;
	background-repeat: no-repeat;
	background-position: center;


                class groundControl extends HTMLElement {
	// static properties are the same on all instances
	static attrs = {
		target: 'control-for',
		setAttr: 'set-attr',
		setProp: 'set-prop',

	static controls = [
	setUp = () => {
		this.resetValue = this.control.value;

		Object.keys(groundControl.attrs).forEach((attr) => {
			this[attr] = this.getAttribute(groundControl.attrs[attr]);

		const selectors = {
			target: this.getAttribute(,
			output: `output[for=${}]`,
			reset: `button[reset-for=${}]`,

		this.targets = document.querySelectorAll(;
		this.displays = document.querySelectorAll(selectors.output);
		this.resetBtn = this.querySelector(selectors.reset);
	// change target attrs/props, and update output displays
	broadCast = () => {
		this.targets.forEach((target) => {
			if (this.setProp) {
			if (this.setAttr) { 
		this.displays.forEach((display) => {
			const units = display.getAttribute('with-units') || '';
			display.value = `${this.control.value}${units}`;
	// reset the value of the control
	resetControl = (value) => {
		this.control.value = value || this.resetValue;
	// callback when an instance of the component first connects
	connectedCallback() {
		this.control = this.querySelector(groundControl.controls.join(', '));
		if (this.control) {
			this.control.addEventListener("input", (e) => this.broadCast());
			this.addEventListener("reset", (e) => this.resetControl());
			if (this.resetBtn) {
				this.resetBtn.addEventListener("click", (e) => this.resetControl());
		} else {
			console.error("Your circuit's dead, there's something wrong");

// register the ground-control element
customElements.define("ground-control", groundControl);

// the reset-all button is not part of the component,
// but triggers the ground-control 'reset' event
	.addEventListener('click', (e) => {
		document.querySelectorAll('ground-control').forEach((control) => {
				new Event("reset", { view: window, bubbles: false })