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

              
                <div class="container" id="container">
  <div class="row">
    <h1><span>clip-path</span> Buttons</h1>
  </div>

  <div class="row">
    <h2>Normal</h2>
  </div>

  <div class="row">
    <div class="box">
      <p>Top to bottom</p>
      <button href="#" class="top-to-bottom">Click on me!</button>
    </div>

    <div class="box">
      <p>Left to right</p>
      <button href="#" class="left-to-right">Click on me!</button>
    </div>

    <div class="box">
      <p>Center out y</p>
      <button href="#" class="center-out-y">Click on me!</button>
    </div>

    <div class="box">
      <p>Center out x</p>
      <button href="#" class="center-out-x">Click on me!</button>
    </div>
  </div>

  <div class="row">
    <h2>Dramatic</h2>
  </div>

  <div class="row">
    <div class="box">
      <p>Top to bottom</p>
      <button href="#" class="top-to-bottom dramatic">Click on me!</button>
    </div>

    <div class="box">
      <p>Left to right</p>
      <button href="#" class="left-to-right dramatic">Click on me!</button>
    </div>

    <div class="box">
      <p>Center out y</p>
      <button href="#" class="center-out-y dramatic">Click on me!</button>
    </div>

    <div class="box">
      <p>Center out x</p>
      <button href="#" class="center-out-x dramatic">Click on me!</button>
    </div>
  </div>
</div>
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css2?family=PT+Mono&family=Poppins:wght@400;600&display=swap");

body {
  background-color: #20232e;
  color: #a1b1e6;
  font-family: "Poppins", sans-serif;
  font-weight: 400;
}

h1,
h2 {
  font-weight: 600;

  span {
    color: #fcba03;
    font-family: "PT Mono", monospace;
  }
}

.container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100vh;
}

.row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
}

.box {
  background-color: #2e3342;
  border: 1px solid #444b61;
  border-radius: 6px;
  margin: 10px;
  padding: 10px 30px;
}

button {
  align-items: center;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  font-family: "Poppins", sans-serif;
  font-size: 18px;
  height: 44px;
  margin: 15px 0;
  padding: 0 25px;
  position: relative;
  text-decoration: none;
  z-index: 1;

  &:before,
  &:after {
    border-radius: 50px;
    content: "";
    display: block;
    left: 0;
    position: absolute;
    top: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    transition: clip-path 275ms ease-in-out;
  }

  &.dramatic:before,
  &.dramatic:after {
    transition: none;
  }

  &:before {
    background: rgb(51, 56, 59);
    background: linear-gradient(
      60deg,
      rgba(58, 62, 82, 1) 0%,
      rgba(96, 103, 136, 1) 100%
    );
    box-shadow: -1px 1px 1px 0px rgba(128, 141, 203, 1) inset,
      0px 0px 0px 4px rgba(14, 16, 20, 0.7);
  }

  &:after {
    background: rgb(165, 58, 180);
    background: linear-gradient(
      90deg,
      rgba(165, 58, 180, 1) 0%,
      rgba(244, 87, 87, 1) 100%
    );
    box-shadow: -1px 1px 1px 0px rgba(247, 147, 147, 1) inset,
      0px 0px 0px 4px rgba(14, 16, 20, 0.7);
  }

  &.left-to-right:after {
    clip-path: inset(0 100% 0 0);
  }

  &.left-to-right:focus:after {
    clip-path: inset(0 0 0 0);
  }

  &.center-out-y:after {
    clip-path: inset(50% 0 50% 0);
  }

  &.center-out-y:focus:after {
    clip-path: inset(0 0 0 0);
  }

  &.center-out-x:after {
    clip-path: inset(0 50% 0 50%);
  }

  &.center-out-x:focus:after {
    clip-path: inset(0 0 0 0);
  }

  &.top-to-bottom:after {
    clip-path: inset(0 0 100% 0);
  }

  &.top-to-bottom:focus:after {
    clip-path: inset(0 0 0 0);
  }

  &.top-to-bottom.dramatic:focus:after {
    animation-name: topToBottom;
    animation-duration: 750ms;
    animation-fill-mode: forwards;
  }

  &.left-to-right.dramatic:focus:after {
    animation-name: leftToRight;
    animation-duration: 750ms;
    animation-fill-mode: forwards;
  }

  &.center-out-y.dramatic:focus:after {
    animation-name: centerOutY;
    animation-duration: 1000ms;
    animation-fill-mode: forwards;
  }

  &.center-out-x.dramatic:focus:after {
    animation-name: centerOutX;
    animation-duration: 1000ms;
    animation-fill-mode: forwards;
  }
}

@keyframes topToBottom {
  0% {
    clip-path: inset(0 0 100% 0);
  }

  20% {
    clip-path: inset(0 0 0 0);
  }

  50% {
    clip-path: inset(0 0 50% 0);
  }

  60% {
    clip-path: inset(0 0 0 0);
  }

  75% {
    clip-path: inset(0 0 30% 0);
  }

  85% {
    clip-path: inset(0 0 0 0);
  }

  90% {
    clip-path: inset(0 0 20% 0);
  }

  94% {
    clip-path: inset(0 0 0 0);
  }

  96% {
    clip-path: inset(0 0 10% 0);
  }

  98% {
    clip-path: inset(0 0 0 0);
  }

  99% {
    clip-path: inset(0 0 3% 0);
  }

  100% {
    clip-path: inset(0 0 0 0);
  }
}

@keyframes leftToRight {
  0% {
    clip-path: inset(0 100% 0 0);
  }

  20% {
    clip-path: inset(0 0 0 0);
  }

  50% {
    clip-path: inset(0 50% 0 0);
  }

  60% {
    clip-path: inset(0 0 0 0);
  }

  75% {
    clip-path: inset(0 30% 0 0);
  }

  85% {
    clip-path: inset(0 0 0 0);
  }

  90% {
    clip-path: inset(0 20% 0 0);
  }

  94% {
    clip-path: inset(0 0 0 0);
  }

  96% {
    clip-path: inset(0 10% 0 0);
  }

  98% {
    clip-path: inset(0 0 0 0);
  }

  99% {
    clip-path: inset(0 3% 0 0);
  }

  100% {
    clip-path: inset(0 0 0 0);
  }
}

@keyframes centerOutY {
  0% {
    clip-path: inset(50% 0 50% 0);
  }

  20% {
    clip-path: inset(0 0 0 0);
  }

  50% {
    clip-path: inset(25% 0 25% 0);
  }

  60% {
    clip-path: inset(0 0 0 0);
  }

  75% {
    clip-path: inset(12.5% 0 12.5% 0);
  }

  85% {
    clip-path: inset(0 0 0 0);
  }

  90% {
    clip-path: inset(6% 0 6% 0);
  }

  94% {
    clip-path: inset(0 0 0 0);
  }

  96% {
    clip-path: inset(3% 0 3% 0);
  }

  98% {
    clip-path: inset(0 0 0 0);
  }

  99% {
    clip-path: inset(1.5% 0 1.5% 0);
  }

  100% {
    clip-path: inset(0 0 0 0);
  }
}

@keyframes centerOutX {
  0% {
    clip-path: inset(0 50% 0 50%);
  }

  20% {
    clip-path: inset(0 0 0 0);
  }

  50% {
    clip-path: inset(0 25% 0 25%);
  }

  60% {
    clip-path: inset(0 0 0 0);
  }

  75% {
    clip-path: inset(0 12.5% 0 12.5%);
  }

  85% {
    clip-path: inset(0 0 0 0);
  }

  90% {
    clip-path: inset(0 6% 0 6%);
  }

  94% {
    clip-path: inset(0 0 0 0);
  }

  96% {
    clip-path: inset(0 3% 0 3%);
  }

  98% {
    clip-path: inset(0 0 0 0);
  }

  99% {
    clip-path: inset(0 1.5% 0 1.5%);
  }

  100% {
    clip-path: inset(0 0 0 0);
  }
}

              
            
!

JS

              
                const container = document.getElementById("container");
container.addEventListener("click", (event) => {
  const isButton = event.target.nodeName === "BUTTON";
  if (!isButton) {
    return;
  }
  event.target.focus();
});

              
            
!
999px

Console