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

              
                //- https://www.frontendmentor.io/challenges/pricing-component-with-toggle-8vPwRMIC
main#main.p-pricing.max-width-4.p2.mx-auto
	.p-pricing__header.center
		h1.h1.bold.mb3.mt4#btn-label Our Pricing
		.p-btn.flex.justify-center.items-center.gray-blue
			span.pr2#anually Annually
			span
				button(aria-describedby="monthly" aria-labelledby="btn-label").btn.btn-toggle.js-toggle#js-btn-price
					.btn-toggle__inner
			span.pl2#monthly Monthly
	.p-pricing__cards.mt4.sm-flex.justify-center.flex-wrap.flex-row.items-center.mb4
		.p-pricing__cards__card.box-shadow-1.p2.bg-white.rounded-12.center.mb2.mx-auto
			h2.bold.p1 Basic
			h3.h00.bold.p-money.mt2.flex.items-center.justify-center
				span.h1 $
				span#basic 19.99
			ul.my2.bold
				li.py2 500 GB Storage
				li.py2 2 Users Allowed
				li.py2 Send up to 3 GB
			.clearfix
				button.btn.btn-primary.caps.bold.h6.col.col-12 Learn more
		.p-pricing__cards__card.box-shadow-1.px2.py3.bg-white.rounded-12.center.bg-blue.white.mb2.mx-auto
			h2.bold.p1 Professional
			h3.h00.bold.p-money.mt2.flex.items-center.justify-center
				span.h1 $
				span#pro 24.99
			ul.my2.bold
				li.py2 1 TB Storage
				li.py2 5 Users Allowed
				li.py2 Send up to 10 GB
			.clearfix
				button.btn.btn-secondary.caps.bold.h6.col.col-12 Learn more
		.p-pricing__cards__card.box-shadow-1.p2.bg-white.rounded-12.center.mb2.mx-auto
			h2.bold.p1 Master
			h3.h00.bold.p-money.mt2.flex.items-center.justify-center
				span.h1 $
				span#master 39.99
			ul.my2.bold
				li.py2 2 TB Storage
				li.py2 10 Users Allowed
				li.py2 Send up to 20 GB
			.clearfix
				button.btn.btn-primary.caps.bold.h6.col.col-12 Learn more
              
            
!

CSS

              
                html {
	font-size: 100%;
}

html, body {
	width: 100%;
	height: 100%;
	overflow-x: hidden;
}

$blue : lighten(blue, 20%);
$blue-light: lighten(blue, 35%);
$gray-blue: lighten(slategray, 5%);
$grayish: lighten(blue, 47%);

body {
	font-family: "Heebo", sans-serif;
	background-color: $grayish;
}

.btn {
	-webkit-appearance: none;
	vertical-align: middle;
	border: none;
	padding: 0.75rem 1rem;
	border-radius: 6px;
	transition: background, color, border 250ms ease;
	&-toggle {
		width: 3rem;
		height: 1.75rem;
		background-color: $blue;
		border-radius: 24px;
		position: relative;
		&:hover {
			background-color: $blue-light;
		}
		&__inner {
			width: 1.25rem;
			height: 1.25rem;
			border-radius: 100%;
			background: white;
			position: absolute;
			margin: 4px;
			left: 0;
			top: 0;
			right: 0;
			box-shadow: 0 5px 5px rgba(blue, 0.1);
			transition: left 250ms ease;
			pointer-events: none;
		}
	}
	&-primary {
		background-color: $blue;
		color: #fff;
		border: 2px solid white;
		&:hover {
			background-color: #fff;
			color: $blue;
			border-color: $blue;
		}
	}
	&-secondary {
		background-color: white;
		color: $blue;
		border: 2px solid $blue;
		&:hover {
			background-color: $blue;
			color: white;
			border-color: white;
		}
	}
}

.bg-white {
	background-color: #fff;
}
.bg-blue {
	background-color: $blue;
}

.white {
	color: #fff;
}

.gray-blue {
	color: $gray-blue;
}
.rounded-12 {
	border-radius: 12px;
}

.box-shadow-1 {
	box-shadow: 0 10px 20px rgba(blue, 0.05)
}
.pro {
	height: 50vh;
}
.p-pricing{
	&__cards {
		&__card {
			width: 100%;
			max-width: 16rem;
			transition: all 250ms ease;
		}
	}
}

.js-toggle {
	.btn-toggle__inner {
		left: 1.25rem;
	}
} 
              
            
!

JS

              
                (function(w, d) {
	"use strict";

	const id = el => d.getElementById(el);
	const q = el => d.querySelector(el);
	const qa = el => d.querySelectorAll(el);
	const on = (el = null, event, handler, options = {}) => {
		if (el !== null) el.addEventListener(event, handler, options);
	};
	const off = (el = null, event, handler) => {
		if (el !== null) el.removeEventListener(event, handler);
	};

	const $btn = id("js-btn-price");
	const $basic = id("basic");
	const $pro = id("pro");
	const $master = id("master");

	on($btn, "click", e => {
		e.preventDefault();
		let el = e.srcElement;
		el.classList.toggle("js-toggle");
		if (el.classList.contains("js-toggle")) {
			el.setAttribute("aria-describedby", "monthly");
			$basic.textContent = 19.99;
			$pro.textContent = 24.99;
			$master.textContent = 39.99;
		} else {
			el.setAttribute("aria-describedby", "annually");
			$basic.textContent = 19.99 * 12;
			$pro.textContent = 24.99 * 12;
			$master.textContent = 39.99 * 12;
		}
	});
})(window, document);

              
            
!
999px

Console