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

              
                <section class="main-section">
	<div class="content-wrapper">
		<div class="image-wrapper">
			<svg width="123" height="22" viewBox="0 0 123 22" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
				<path d="M10.5534 21.4541L0 11.0106L10.5534 0.545166L16.7095 0.545166L6.15614 11.0106L16.7095 21.4541L10.5534 21.4541Z"></path>
				<path d="M16.4736 11C16.7009 9.31818 17.2009 7.81818 17.9736 6.45455C18.7236 5.09091 19.6781 3.93182 20.8145 2.97727C21.9509 2.02273 23.2463 1.29545 24.7009 0.772727C26.1554 0.25 27.7009 0 29.3372 0C30.9736 0 32.4509 0.25 33.7463 0.772727C35.0418 1.29545 36.1327 2.02273 36.9963 2.97727C37.86 3.93182 38.4736 5.09091 38.86 6.45455C39.2236 7.81818 39.2918 9.34091 39.0645 11C38.8372 12.6818 38.3372 14.1818 37.5872 15.5455C36.8372 16.9091 35.8827 18.0682 34.7463 19.0227C33.61 19.9773 32.3145 20.7045 30.86 21.2273C29.4054 21.75 27.86 22 26.2463 22C24.61 22 23.1327 21.75 21.8372 21.2273C20.5191 20.7045 19.4281 19.9773 18.5645 19.0227C17.7009 18.0682 17.0872 16.9091 16.7009 15.5455C16.3145 14.1818 16.2463 12.6591 16.4736 11ZM21.2691 11C21.1327 11.9773 21.1554 12.8864 21.36 13.7045C21.5645 14.5227 21.9054 15.2273 22.3827 15.8409C22.86 16.4318 23.4736 16.9091 24.2236 17.25C24.9736 17.5909 25.8372 17.75 26.8145 17.75C27.7918 17.75 28.7236 17.5909 29.5645 17.25C30.4054 16.9091 31.1554 16.4545 31.8145 15.8409C32.4736 15.25 32.9963 14.5227 33.4281 13.7045C33.86 12.8864 34.1327 11.9773 34.2691 11C34.4054 10.0455 34.3827 9.13636 34.2009 8.31818C34.0191 7.5 33.6781 6.77273 33.1781 6.18182C32.6781 5.59091 32.0645 5.11364 31.3145 4.77273C30.5645 4.43182 29.7009 4.27273 28.7236 4.27273C27.7463 4.27273 26.8145 4.43182 25.9736 4.77273C25.1327 5.11364 24.3827 5.56818 23.7236 6.18182C23.0645 6.77273 22.5418 7.5 22.11 8.31818C21.6781 9.13636 21.4054 10.0227 21.2691 11Z"></path>
				<path d="M43.2841 0.523437L49.5568 0.523437L56.4204 15.0689H56.4886L58.5341 0.523437L63.1477 0.523437L60.2159 21.4325L54.1932 21.4325L47.125 6.54616H47.0568L44.9886 21.4325H40.375L43.2841 0.523437Z"></path>
				<path d="M71.2404 4.6131L65.2632 4.6131L65.8314 0.544922L82.3768 0.544922L81.8086 4.6131L75.8313 4.6131L73.4677 21.454H68.8541L71.2404 4.6131Z"></path>
				<path d="M83.906 9.18208L91.2242 9.18208C91.6333 9.18208 92.0651 9.15935 92.5424 9.13663C92.9969 9.1139 93.4287 9.02299 93.8378 8.8639C94.2242 8.72754 94.5651 8.47754 94.8606 8.15936C95.156 7.84117 95.3378 7.40935 95.4287 6.81845C95.4969 6.29572 95.4515 5.8639 95.2924 5.54572C95.1106 5.22754 94.8606 5.00026 94.5651 4.81845C94.2469 4.65936 93.8833 4.54572 93.4515 4.47754C93.0197 4.40936 92.6106 4.38663 92.2015 4.38663L85.9287 4.38663H84.6106L85.156 0.477539L93.2469 0.477539C94.3151 0.477539 95.3151 0.591175 96.2242 0.795721C97.156 1.00027 97.9287 1.34118 98.5878 1.81845C99.2469 2.29572 99.7242 2.95481 100.042 3.77299C100.361 4.59117 100.429 5.6139 100.247 6.84117C100.02 8.31845 99.4742 9.56845 98.5651 10.6139C97.656 11.6594 96.4515 12.2957 94.9287 12.5684L98.9969 21.4093L93.4742 21.4093L90.2469 13.0457H87.9742L83.3833 13.0684L83.906 9.18208Z"></path>
				<path d="M108.153 17.0222L105.789 21.454H100.698L112.653 0.544922L116.494 0.544922L122.676 21.454H117.471L116.289 17.0222L113.607 6.6131L108.153 17.0222Z"></path>
			</svg>
		</div>
		<h1>Dark mode on everything?</h1>
		<p>To change the theme color, press the slider button below</p>
		<div class="theme-switch-wrapper">
			<label class="theme-switch" for="checkbox">
				<input type="checkbox" id="checkbox" />
				<div class="slider round"></div>
			</label>
		</div>
		<div class="additional-info">
			<p>Go back to the <a href="https://kontra.agency/how-to-implement-dark-mode/" target="_blank">article</a></p>
		</div>
	</div>
</section>
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css2?family=DM+Sans&family=Roboto:wght@400;500;700&display=swap");
/* Main light theme */
:root {
	--primary-color: #ff4732;
	--secondary-color: #536390;
	--font-color: #000;
	--bg-color: #f7f4f2;
	--heading-color: #292922;
	--logo-color: #ff4732;
}
/* Dark theme */
[data-theme="dark"] {
	--primary-color: #ff4732;
	--secondary-color: #f2af29;
	--font-color: #818cab;
	--bg-color: #010c50;
	--heading-color: #f7f4f2;
	--logo-color: #f7f4f2;
}
* {
	padding: 0px;
	margin: 0px;
	box-sizing: border-box;
	font-family: "Roboto", serif;
	font-weight: 400;
	font-size: 16px;
}
*:after,
*:before {
	-webkit-box-sizing: border-box;
	-moz-box-sizing: border-box;
	box-sizing: border-box;
}
a:hover,
a:focus {
	outline: none;
}
.main-section {
	width: 100%;
	height: 100vh;
	background-color: var(--bg-color);
	transition: 500ms background ease;
}
.main-section .content-wrapper {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	height: 100%;
}
.main-section .content-wrapper h1 {
	font-size: 3rem;
	margin-bottom: 20px;
	font-weight: 700;
	color: var(--heading-color);
	transition: 500ms all ease;
}
.main-section .content-wrapper p {
	margin-bottom: 10px;
	color: var(--font-color);
	transition: 500ms all ease;
}
.content-wrapper .additional-info {
	margin-top: 1rem;
}
a {
	color: var(--secondary-color);
	text-decoration: underline;
	text-underline-offset: 3px;
	text-decoration-thickness: 2px;
	font-weight: 500;
	transition: 500ms all ease;
	position: relative;
	display: inline-block;
	text-transform: uppercase;
}
a:hover {
	opacity: 0.5;
}
.main-section .content-wrapper .image-wrapper {
	margin-bottom: 1.5rem;
}
.main-section .content-wrapper .image-wrapper svg {
	width: 200px;
	height: 100px;
}
.main-section .content-wrapper .image-wrapper svg path {
	fill: var(--logo-color);
	transition: 500ms fill ease;
}
/* Theme toggler */
.theme-switch-wrapper {
	margin-top: 1rem;
	display: flex;
	align-items: center;
}
.theme-switch {
	display: inline-block;
	height: 34px;
	position: relative;
	width: 60px;
}
.theme-switch input {
	display: none;
}
.slider {
	background-color: #ccc;
	bottom: 0;
	cursor: pointer;
	left: 0;
	position: absolute;
	right: 0;
	top: 0;
	transition: 0.4s;
}
.slider:before {
	background-color: #fff;
	bottom: 4px;
	content: "";
	height: 26px;
	left: 4px;
	position: absolute;
	transition: 0.4s;
	width: 26px;
}
input:checked + .slider {
	background-color: var(--primary-color);
}

input:checked + .slider:before {
	transform: translateX(26px);
}
.slider.round {
	border-radius: 34px;
}
.slider.round:before {
	border-radius: 50%;
}

              
            
!

JS

              
                const toggleSwitch = document.querySelector(
	'.theme-switch input[type="checkbox"]'
);
const currentTheme = localStorage.getItem("theme");

function switchTheme(e) {
	if (e.target.checked) {
		document.documentElement.setAttribute("data-theme", "dark");
		localStorage.setItem("theme", "dark");
	} else {
		document.documentElement.setAttribute("data-theme", "light");
		localStorage.setItem("theme", "light");
	}
}

toggleSwitch.addEventListener("change", switchTheme, false);

if (currentTheme) {
	document.documentElement.setAttribute("data-theme", currentTheme);

	if (currentTheme === "dark") {
		toggleSwitch.checked = true;
	}
}

              
            
!
999px

Console