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

              
                <h1>Theme Switching Toggle</h1>
<a href="#">a link</a>

<!-- Added a fieldset, ARIA roles, and heading (can be outer or within a legend if you prefer. Thanks to Steve Faulkner and Heydon Pickering https://twitter.com/stevefaulkner/status/1021327778334019585 & https://twitter.com/heydonworks/status/1021329851066830848 -->

<fieldset aria-label="theme switcher" role="radiogroup">
<!-- 	<legend><h1>Theme Switching Toggle</h1></legend> -->
<div class="c-toggle">
	<label for="light">Light</label>
	<span class="c-toggle__wrapper">
		<input type="radio" name="theme" id="light" checked>
		<input type="radio" name="theme" id="dark">
		<span aria-hidden="true" class="c-toggle__background"></span>
		<span aria-hidden="true" class="c-toggle__switcher"></span>
	</span>
	<label for="dark">Dark</label>
</div>
</fieldset>
<a href="#">another link</a>

              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css?family=Nunito:300,400,700");

body {
	padding: 5vw 10vw;
	font-size: 18px;
	font-family: "Nunito", sans-serif;
}

.c-toggle {
	--baseSize: 12px;
	
	label {
		font-size: calc(var(--baseSize) * 1.75);
		margin: 0 .5em 0;
		cursor: pointer;
	}
	
	input[type="radio"] {
		display: inline-block;
		margin-right: -2px;
		width: 50%;
		height: 100%;
		opacity: 0;
		position: relative;
		z-index: 1;
		cursor: pointer;
		
		&:focus ~ .c-toggle__switcher {
			border: 3px solid hsla(333, 40%, 45%, 1);
			top: -2px;
		}
	}
}

.c-toggle__wrapper {
	font-size: var(--baseSize);
	display: inline-block;
	vertical-align: middle;
	width: 7em;
	height: 3.5em;
	border-radius: 3.5em; /* = height */
	border: 1px solid #ddd;
	position: relative; // create positioning context for ::after
}
.c-toggle__switcher {
	// the toggle
	display: block;
	position: absolute;
	top: 0;
	left: 0;
	right: 100%;
	width: 50%;
	height: 100%;
	border-radius: 50%;
	background-color: hsla(333, 60%, 60%, 1);
	transition: all 0.1s ease-out;
	z-index: 2;
}

.c-toggle__background {
	display: block;
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 0;
	border-radius: 3.5em;
	background-color: #eee;
	transition: all 0.1s ease-out;
}

#dark:checked ~ .c-toggle__switcher {
	right: 0;
	left: 50%;
}

#dark:checked ~ .c-toggle__background {
	background-color: #333;
}



a {
	display: block;
	margin: 2em 0;
	padding: .5em;
	
	&:focus {
		outline: 3px solid;
	}
}

/* support Windows High Contrast Mode. Credit: Adrian Roselli https://twitter.com/aardrian/status/1021372139990134785 */
@media screen and (-ms-high-contrast: active) {
  .c-toggle__switcher {
    background-color: windowText;
  }
}


fieldset {
	border: none;
}
              
            
!

JS

              
                
              
            
!
999px

Console