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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                .actions
	.actions__title Create a new alert:
	button.button.button--success(onclick="createAlert('success')") Success
	button.button.button--danger(onclick="createAlert('danger')") Danger
	button.button.button--warning(onclick="createAlert('warning')") Warning
	button.button(onclick="createAlert('default')") Default

.wrapper
	.alert.alert--success
		svg.alert__icon(width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg")
			circle.alert__icon-path(cx="32" cy="32" r="30.5" stroke="currentColor")
			path.alert__icon-path.alert__icon-path--type(d="M15 33.5L25 43.5L48.5 20" stroke="currentColor")
		.alert__message This is a success notificiation
		.alert__close &times;
		
	.alert.alert--danger
		svg.alert__icon(width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg")
			circle.aalert__icon-path(cx="32" cy="32" r="30.5" stroke="currentColor" stroke-width="5")
			path.alert__icon-path.alert__icon-path--type(d="M20 44L44 20" stroke="currentColor")
			path.alert__icon-path.alert__icon-path--type(d="M44 44L20 20" stroke="currentColor")
		.alert__message This is a danger notificiation
		.alert__close &times;
		
	.alert.alert--warning
		svg.alert__icon(width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg")
			circle.alert__icon-path(cx="32" cy="32" r="30.5" stroke="currentColor")
			path.alert__icon-path.alert__icon-path--type(d="M32 19V38" stroke="currentColor")
			path.alert__icon-path.alert__icon-path--type(d="M32 41L32 45" stroke="currentColor")
		.alert__message This is a warning notificiation
		.alert__close &times;
		
	.alert
		svg.alert__icon(width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg")
			circle.alert__icon-path(cx="32" cy="32" r="30.5" fill="currentColor" style="opacity: .2")
			circle.alert__icon-path(cx="32" cy="32" r="30.5" stroke="currentColor")
		.alert__message This is a default notificiation
		.alert__close &times;
              
            
!

CSS

              
                $blue: #09C8FF;
$red: #FF4555;
$green: #39D7B3;
$yellow: #FFBA4B;

$text: #677b7a;

.alert {
	background: white;
	width: 100%;
	display: flex;
	padding: 1rem;
	align-items: center;
	border-radius: .8rem;
	border: 2px solid;
	margin-bottom: 1rem;
	position: relative;
	box-shadow: 0px 5px 12px rgba(black, .04), 0px 12px 25px rgba(black, .07);
	animation: transitionIn 200ms ease forwards;
	transition: all 200ms ease;
	&__message {
		color: $text;
	}
	&__close {
		$size: 1.3rem;
		width: $size;
		height: $size;
		line-height: $size;
		color: $text;
		text-align: center;
		position: absolute;
		top: .5rem;
		right: .5rem;
		cursor: pointer;
		border-radius: .4rem;
		&:hover, &:focus {
			background: rgba($text, .2);
		}
	}
	&__icon {
		margin-right: 1rem;
		$animation-time: 500ms;
		$size: 36px;
		width: $size;
		height: $size;
		animation: fade 500ms linear forwards;
	}
	&__icon-path {
		stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
		stroke-width: 4px;
  animation: dash 1s ease forwards;
		&--type {
			animation-delay: 300ms;
			animation-duration:5s;
		}
	}
	&--success {
		$color: $green;
		color: $color;
		border-color: $color;
	}
	&--warning {
		$color: $yellow;
		color: $color;
		border-color: $color;
	}
	&--danger {
		$color: $red;
		color: $color;
		border-color: $color;
	}
}

@keyframes dash {
  from {
    stroke-dashoffset: 1000;
  }
  to {
    stroke-dashoffset: 0;
  }
}

// demo

html {
	box-sizing: border-box;
}

*, *:before, *:after {
	box-sizing: inherit;
}

html, body {
	height: 100%;
}

body {
	color: $text;
	font-family: system-ui;
}

.wrapper {
	max-width: 500px;
	width: 100%;
	margin: auto;
	padding-top: 15vh;
		padding-left: .5rem;
	padding-right: .5rem;
}

.actions {
	position: fixed;
	bottom: 0;
	right: 0;
	left: 0;
	z-index: 100;
	width: 100%;
	display: flex;
	justify-content: space-evenly;
	flex-wrap: wrap;
	&__title {
		width: 100%;
		text-align: center;
		padding-bottom: .5rem;
		font-weight: 700;
		text-transform: uppercase;
		letter-spacing: .1em;
		font-size: 85%;
	}
	.button {
		display: block;
		width: 25%;
	}
}

.button {
	font-family: inherit;
	background: transparent;
	color: white;
	background: $text;
	border: 0;
	padding: 1rem;
	cursor: pointer;
	margin: 0;
	&:hover {
		opacity: .8;
	}
	&--success {
		background: $green;
		&:focus, &:active {
			box-shadow: 0px 0px 0px 3px rgba($green, .4);
		}
	}
	&--danger {
		background: $red;
		&:focus, &:active {
			box-shadow: 0px 0px 0px 3px rgba($red, .4);
		}
	}
	&--warning {
		background: $yellow;
		&:focus, &:active {
			box-shadow: 0px 0px 0px 3px rgba($yellow, .4);
		}
	}
	&:focus, &:active {
		outline: 0;
	}
}

@keyframes fade {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}
              
            
!

JS

              
                console.clear();

const wrapper = document.querySelector('.wrapper');

const closeAlertItem = () => {
	const alertClose = document.querySelectorAll('.alert__close');
	alertClose.forEach(item => {
		item.addEventListener('click', function() {
			item.parentNode.style.transform = 'translateX(3rem)';
			item.parentNode.style.opacity = '0';
			setTimeout(() => {
				item.parentNode.remove();
				emptyState();
			}, 100)
		})
	})
}

const emptyState = () => {
	if(wrapper.children.length > 0) {
		if(document.querySelector('.empty-state')) {
			document.querySelector('.empty-state').remove();
		}
	} else {
		const emptyItem = document.createElement('div');
		emptyItem.classList = 'empty-state';
		emptyItem.style.textAlign = 'center';
		emptyItem.style.fontSize = '2rem';
		emptyItem.innerHTML = 'There are no alerts';
		wrapper.appendChild(emptyItem);
	}
}

const createAlert = (type) => {
	const newAlert = document.createElement('div');
	newAlert.classList = `alert alert--${type}`;
	if(type == 'success') {
		newAlert.innerHTML = `
			<svg class="alert__icon" width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
				<circle class="alert__icon-path" cx="32" cy="32" r="30.5" stroke="currentColor"></circle>
				<path class="alert__icon-path alert__icon-path--type" d="M15 33.5L25 43.5L48.5 20" stroke="currentColor"></path>
			</svg>
			<div class="alert__message">This is a ${type} notificiation</div>
		<div class="alert__close">&times;</div>`;
	} else if(type == 'danger') {
		newAlert.innerHTML = `
			<svg class="alert__icon" width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
				<circle class="aalert__icon-path" cx="32" cy="32" r="30.5" stroke="currentColor" stroke-width="5"></circle>
				<path class="alert__icon-path alert__icon-path--type" d="M20 44L44 20" stroke="currentColor"></path>
				<path class="alert__icon-path alert__icon-path--type" d="M44 44L20 20" stroke="currentColor"></path>
			</svg>
			<div class="alert__message">This is a ${type} notificiation</div>
			<div class="alert__close">&times;</div>
		`;
	} else if(type == 'warning') {
		newAlert.innerHTML = `
			<svg class="alert__icon" width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
				<circle class="alert__icon-path" cx="32" cy="32" r="30.5" stroke="currentColor"></circle>
				<path class="alert__icon-path alert__icon-path--type" d="M32 19V38" stroke="currentColor"></path>
				<path class="alert__icon-path alert__icon-path--type" d="M32 41L32 45" stroke="currentColor"></path>
			</svg>
			<div class="alert__message">This is a ${type} notificiation</div>
			<div class="alert__close">&times;</div>
		`;
	} else {
		newAlert.innerHTML = `
			<svg class="alert__icon" width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
      <circle class="alert__icon-path" cx="32" cy="32" r="30.5" fill="currentColor" style="opacity: .2;"></circle>
      <circle class="alert__icon-path" cx="32" cy="32" r="30.5" stroke="currentColor"></circle>
    </svg>
			<div class="alert__message">This is a ${type} notificiation</div>
			<div class="alert__close">&times;</div>
		`;
	}
	wrapper.appendChild(newAlert);
	newAlert.style.transform = 'translateX(-3rem)';
	newAlert.style.opacity = '0';
	setTimeout(() => {
		newAlert.style.transform = 'translateX(0)';
		newAlert.style.opacity = '1';
	}, 100)
	closeAlertItem();
	emptyState();
}

closeAlertItem();
              
            
!
999px

Console