Pen Settings



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


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.


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.


  <button class="add">Add +</button>


                :root {
  --notification-size: 350px;

.notification {
  position: fixed;
  display: flex;
  width: var(--notification-size);
  right: var(--space-4);
  border: var(--border);
  background-color: var(--color-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-large);
  transition: var(--transition);
  animation: slide-in var(--transition-speed) var(--transition-curve);
.content {
  padding: var(--space-4);
.title {
  font-size: var(--text-md);
  margin-bottom: var(--space-1);
  font-weight: bold;
  color: var(--color-gray-800);
.description {
  color: var(--color-gray-600);
.close {
  font-size: var(--text-sm);
  margin-left: auto;
  padding: 0 var(--space-4);
  border: 0;
  border-left: var(--border);
  background-color: transparent;
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--color-gray-400);
  cursor: pointer;
.close:hover {
  background-color: var(--color-gray-100);
.close:active {
  color: var(--color-gray-700);
.close:active {
  outline: none;
  box-shadow: var(--shadow-focus);
.add {
  padding: var(--space-3) var(--space-5);
  border: 0;
  font-weight: bold;
  background-color: var(--color-blue-500);
  color: var(--color-white);
  border-radius: var(--round);
  cursor: pointer;
  outline: none;
.add:hover {
  background-color: var(--color-blue-400);
.add:focus {
  box-shadow: var(--shadow-focus);
.add:active {
  background-color: var(--color-blue-500);
.animate-out {
  animation: fade-out var(--transition-speed) var(--transition-curve);
@keyframes fade-out {
  to {
    opacity: 0;
    transform: translateX(var(--notification-size));
@keyframes slide-in {
  from {
    transform: translateX(var(--notification-size));
  to {
    transform: translateX(0);



                const notificationTexts = [
  "Hey Jussi! If you're recording your screen, I just wanted to tell that...",
  "Congratulations, you've found the meaning of life, which by the way is being present.",
  "You looked super today! Where's that smile from?",
  "How are you doing? Dismiss this message to tell me that you've seen it.",
  "Dude, I've never slided so smoothly into anything before! Well, that sounded a bit weird to be honest.",
  "Did you know that LASER is an abbreviation for Light Amplification by the Stimulated Emission of Radiation?"

const addButton = document.querySelector(".add");
const notificationPosition = document.body.querySelector("div");
const margin = 16;

const addNotification = () => {
  // Create notification
  const notification = document.createElement("div");
  // Add class "notification"
  // Pick random content for notification
  const randomMessage =
    notificationTexts[Math.floor(Math.random() * notificationTexts.length)];
  // Insert random content and close button
  notification.innerHTML = `
                    <div class="content">
            <h4 class="title">New message!</h4>
            <p class="description">${randomMessage}</p>
          <button class="close" aria-label="Dismiss notification">Close</button>
  // Get close button within notification
  const closeButton = notification.querySelector(".close");
  // Listen for the button and attach "removeNotification" function to it
  closeButton.addEventListener("click", removeNotification);
  // Position notification = `${margin}px`;
  // Add notification on the page
  // Move other notifications down
  // 1. Get height of the newly added notification
  const currentHeight = notification.offsetHeight;
  // 2. Get the rest of the notifications and turn them into an array
  const restNotifications = Array.from(
  // 3. Add the currently added notification's height to the rest of the notifications
  restNotifications.forEach((item) => { = `${parseInt( + currentHeight + margin}px`;

const removeNotification = (event) => {
  // Get clicked close button
  const closeButton = event.currentTarget;
  // Get the notification
  const notification = closeButton.parentNode;
  // Get the height of the clicked notification
  const currentHeight = notification.offsetHeight;
  // Define rest of the notifications
  let restNotifications = [];
  let next = notification.nextElementSibling;
  // Loop always the next notification until none is found
  while (next) {
    // If the next element doesn't have 'notification' class, break the while loop
    if (!next.matches(".notification")) {
    // Add the notification to the array
    // Set the next to be the next element
    next = next.nextElementSibling;
  // Se the new height for each of the notifications below the removed one
  restNotifications.forEach((item) => { = `${parseInt( - currentHeight - margin}px`;
  // Animate removed notification
  // Remove notification once animation has ended
  notification.addEventListener("animationend", () => {

addButton.addEventListener("click", addNotification);