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

              
                <div class="sidebar-container">
        <div class="sidebar-items">
            <div class="active-circle"></div>
            <div class="sidebar-item active" data-active-offset="13px" data-active-index="0">
                <svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path><polyline points="9 22 9 12 15 12 15 22"></polyline></svg>
                <span class="title">Home</span>
            </div>

            <div class="sidebar-item" data-active-offset="62px" data-active-index="1">
                <svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke-linecap="round" stroke-linejoin="round"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path><circle cx="12" cy="7" r="4"></circle></svg>
                <span class="title">Contacts</span>
            </div>

            <div class="sidebar-item" data-active-offset="121px" data-active-index="2">
                <svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke-linecap="round" stroke-linejoin="round"><path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"></path></svg>
                <span class="title">Messages</span>
            </div>

            <div class="sidebar-item" data-active-offset="178px" data-active-index="3">
                <svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><circle cx="8.5" cy="8.5" r="1.5"></circle><polyline points="21 15 16 10 5 21"></polyline></svg>
                <span class="title">Pictures</span>
            </div>

            <div class="sidebar-item" data-active-offset="229px" data-active-index="4">
                <svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"></circle><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"></path></svg>
                <span class="title">Setting</span>
            </div>
        </div>
    </div>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css2?family=Lato&display=swap');
html,
body,
* {
    padding: 0;
    margin: 0;
}

body {
    width: 100vw;
    min-height: 100vh;
    background-color: #212526;
    // to center
    display: grid;
    place-content: center;
}

:root {
    --active-offset: 13px;
}

.sidebar-container {
    width: 300px;
    height: 55px;
    position: relative;
    .sidebar-items {
        width: 100%;
        height: 100%;
        background-color: rgba($color: #fff, $alpha: .95);
        border-radius: 7px;
        position: absolute;
        z-index: 1;
        display: flex;
        align-items: center;
        justify-content: space-around;
        padding: 0 20px;
        padding-top: 3px;
        box-sizing: border-box;
    }
}

.sidebar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    .icon {
        width: 22px;
        stroke: #000;
        stroke-width: 1.5px;
        position: absolute;
        z-index: 4;
        bottom: 0;
        transition: bottom .4s;
        cursor: pointer;
    }
    .title {
        font-family: 'Lato', sans-serif;
        font-size: .8rem;
        font-weight: bold;
        position: relative;
        top: 30px;
        opacity: 0;
        transition: top .4s, opacity .4s;
    }
}

.active-circle {
    width: 45px;
    height: 45px;
    background-color: rgba(62, 227, 135, 1);
    position: absolute;
    top: -53%;
    border-radius: 50%;
    z-index: 2;
    border: 5px solid #212526;
    left: var(--active-offset);
    transition: left .4s;
}

.sidebar-item.active {
    .icon {
        bottom: 26px;
    }
    .title {
        top: 10px;
        opacity: .9;
    }
}
              
            
!

JS

              
                "use strict";
const $ = document;
const root = $.querySelector(":root");
let activeItem = 0;
const sidebar = {
    items: $.querySelectorAll(".sidebar-item"),
}
for (let item of sidebar.items) {
    item.addEventListener("click", setNewActive)
}

function setNewActive() {
    let activeOffset = this.dataset.activeOffset;
    let activeIndex = parseInt(this.dataset.activeIndex);
    sidebar.items[activeItem].classList.remove("active");
    sidebar.items[activeIndex].classList.add("active");
    activeItem = activeIndex;
    root.style.setProperty("--active-offset", activeOffset)
}
              
            
!
999px

Console