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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

              
                <button class="unlock-btn">
  <div class="locker-placeHolder"></div>
  <div class="read-ok">
    <svg width="27" height="20" viewBox="0 0 27 20" fill="none" xmlns="http://www.w3.org/2000/svg">
      <path d="M3 9.5L10 16L24 3" stroke="white" stroke-width="5" stroke-linecap="round" />
    </svg>
  </div>
  <div class="locker-area">
    <div class="locker">
      <svg class="locker-head" width="34" height="41" viewBox="0 0 34 41" fill="none" xmlns="http://www.w3.org/2000/svg">
        <path fill-rule="evenodd" clip-rule="evenodd" d="M12.0968 12.6839C11.1539 13.8322 10.7407 15.3606 10.7407 16.6032V35H4V16.6032C4 14.1299 4.76939 11.026 6.86742 8.47087C9.06581 5.79355 12.4996 4 17.1689 4C21.6987 4 24.9976 6.06894 27.0798 8.6843C29.0655 11.1783 30 14.2215 30 16.6032V25.8431C30 27.6869 28.491 29.1815 26.6296 29.1815C24.7682 29.1815 23.2593 27.6869 23.2593 25.8431V16.6032C23.2593 15.7336 22.8423 14.1444 21.787 12.8188C20.8282 11.6147 19.3969 10.6769 17.1689 10.6769C14.4049 10.6769 12.9394 11.6578 12.0968 12.6839Z" fill="#282F38" />
        <g filter="url(#filter0_f)">
          <path d="M25.6296 25.8431C25.6296 26.3954 26.0773 26.8431 26.6296 26.8431C27.1819 26.8431 27.6296 26.3954 27.6296 25.8431H25.6296ZM8.37036 35V16.6032H6.37036V35H8.37036ZM8.37036 16.6032C8.37036 14.9319 8.90752 12.853 10.255 11.212C11.573 9.60682 13.7314 8.3385 17.1689 8.3385V6.3385C13.1731 6.3385 10.4321 7.84463 8.70928 9.94283C7.01579 12.0053 6.37036 14.5587 6.37036 16.6032H8.37036ZM17.1689 8.3385C20.2101 8.3385 22.2987 9.67592 23.6511 11.3745C25.0323 13.1094 25.6296 15.2065 25.6296 16.6032H27.6296C27.6296 14.7486 26.8754 12.2134 25.2157 10.1288C23.5271 8.00777 20.8854 6.3385 17.1689 6.3385V8.3385ZM25.6296 16.6032V25.8431H27.6296V16.6032H25.6296Z" fill="#7B8698" />
        </g>
        <defs>
          <filter id="filter0_f" x="0.370361" y="0.338501" width="33.2593" height="40.6615" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
            <feFlood flood-opacity="0" result="BackgroundImageFix" />
            <feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
            <feGaussianBlur stdDeviation="3" result="effect1_foregroundBlur" />
          </filter>
        </defs>
      </svg>
      <div class="locker-body"></div>
    </div>
  </div>
  <span class="message">UNLOCK</span>
  <span class="unlock-msg">Read</span>
  <div class="drop"></div>
</button>

<footer>
  <p>original design credits to: <a href="https://dribbble.com/shots/15522609-Button-Lock-Animation">https://dribbble.com/shots/15522609-Button-Lock-Animation</a></p>
</footer>
              
            
!

CSS

              
                body {
  background: #27282d;
  color: #fff;
}
footer {
  position: fixed;
  bottom: 10px;
}
.unlock-btn {
  /* variables */
  --button-width: 250px;
  --button-background: linear-gradient(180deg, #3385ff 0%, #2075f4 100%);
  --locker-size: 50px;
  --locker-background: rgba(104, 164, 255, 0.5);

  /* style */
  position: absolute;
  display: flex;
  justify-content: space-around;
  align-items: center;
  width: var(--button-width);
  height: 80px;
  left: calc(50% - var(--button-width) / 2);
  top: 100px;
  background: var(--button-background);
  box-shadow: inset 0px 4px 10px rgba(255, 255, 255, 0.2);
  border-radius: 1000px;
  border: 0;
  cursor: pointer;

  &:hover {
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0.15)),
      linear-gradient(180deg, #3385ff 0%, #2075f4 100%);
  }

  .message,
  .unlock-msg {
    font-size: 28px;
    color: #fff;
  }

  .unlock-msg {
    position: absolute;
    transform: translate3d(0px, 0px, 0);
    opacity: 0;
  }

  .read-ok,
  .locker-placeHolder {
    position: relative;
    width: var(--locker-size);
    height: var(--locker-size);
    box-sizing: border-box;
    border: 4px solid #68a4ff;
    border-radius: 50%;
    backdrop-filter: blur(calc(2 * 1px));
    position: absolute;
    left: 10px;
  }

  .read-ok {
    border: 4px solid #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
  }

  .drop {
    position: relative;
    width: var(--locker-size);
    height: var(--locker-size);
    box-sizing: border-box;
    border: 4px solid #68a4ff;
    border-radius: 50%;
    backdrop-filter: blur(calc(2 * 1px));
  }
  .locker-area {
    position: relative;
    width: var(--locker-size);
    height: var(--locker-size);
    background: var(--locker-background);
    border-radius: 50%;
    box-sizing: border-box;
    border: 4px solid #fff;
    backdrop-filter: blur(calc(2 * 1px));
    &::after {
      width: 10px;
      position: absolute;
      height: calc(var(--button-width) / 10);
      content: " ";
      background: linear-gradient(180deg, #3183ff 0%, #2379f9 100%);
      left: 50%;
      transform: translate3d(-50%, -50%, 0);
      top: 50%;
    }
    .locker-head {
      position: absolute;
      transform: translate3d(-50%, 30%, 0);
    }
    .locker-body {
      height: 40px;
      width: 45px;
      border-radius: 12px;
      background: linear-gradient(180deg, #f4f7fc 0%, #e3e6ea 100%);
      box-shadow: inset 0px 4px 6px rgb(255 255 255 / 50%),
        inset 0px -5px 17px rgb(0 0 0 / 40%);
      transform: translate3d(-1px, 100%, 0);
    }
  }
}

              
            
!

JS

              
                gsap.registerPlugin(Draggable);

const button = document.querySelector(".unlock-btn");
const lockerArea = button.querySelector(".locker-area");
const locker = button.querySelector(".locker");
const lockerHead = button.querySelector(".locker-head");
const lockerBody = button.querySelector(".locker-body");
const dropArea = button.querySelector(".drop");

let tl = gsap.timeline({ paused: true }); //create the timeline
tl.to(lockerBody, {
  y: "120%",
  duration: 0.2
})
  .to(locker, {
    keyframes: [
      {
        rotation: -45,
        x: -8,
        transformOrigin: "center",
        duration: 0.2
      },
      {
        x: -15,
        y: -1,
        duration: 0.2
      },
      {
        x: -30,
        y: 10,
        duration: 0.2
      },
      {
        y: 100,
        opacity: 0,
        duration: 0.2
      }
    ]
  })
  .to(lockerArea, {
    rotation: -90,
    duration: 0.3
  })
  .to(".message,.drop,.locker-area", {
    y: 30,
    opacity: 0,
    duration: 0.1
  })
  .fromTo(
    ".read-ok, .unlock-msg",
    {
      y: -30,
      opacity: 0
    },
    {
      opacity: 1,
      y: 0,
      duration: 0.2
    }
  );

Draggable.create(lockerArea, {
  type: "x",
  bounds: button,
  onDrag(e) {},
  onRelease(e) {
    if (!this.hitTest(dropArea)) {
      gsap.to(lockerArea, {
        x: 0,
        duration: 0.6,
        ease: "elastic.out(1, .75)"
      });
    } else {
      this.disable();
      gsap.to(lockerArea, {
        x: dropArea.offsetLeft - 9,
        duration: 0.6,
        ease: "elastic.out(1, .8)",
        onUpdate(e) {
          tl.restart();
        }
      });
    }
  }
});

              
            
!
999px

Console