AI CSS Animations

Curl Top Right Hover Effect

The top right corner of the button peels over on hover like a page, showing its lighter back and a soft shadow. A clip-path cuts the corner while a gradient square plays the folded flap.

Also known as: hvr-curl-top-right, folded corner button css, page peel hover.

HTML

<button class="hfx-curl-top-right"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5M9 13h6M9 17h4"/></svg>Read the report</button>

CSS

.hfx-curl-top-right {
  --c: var(--hfx-color, #3b82f6);
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.7em 1.6em;
  border-radius: 0.5em;
  font: 600 var(--hfx-size, 16px) system-ui, sans-serif;
  cursor: pointer;
  border: 0;
  background: var(--c);
  color: #fff;
  position: relative;
  clip-path: polygon(0 0, 100% 0, 100% 0, 100% 100%, 0 100%);
  transition: clip-path 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);}
.hfx-curl-top-right svg {
  width: 1.1em;
  height: 1.1em;
}
/* the flap: the cut corner mirrored across the fold, lighter like the back of the paper */
.hfx-curl-top-right::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 1.4em;
  height: 1.4em;
  border-bottom-left-radius: 0.3em;
  background: linear-gradient(225deg, transparent 50%, color-mix(in srgb, var(--c) 45%, #fff) 50%, color-mix(in srgb, var(--c) 8%, #fff) 90%);
  box-shadow: -0.12em 0.12em 0.25em rgb(0 0 0 / 0.3);
  transform: scale(0);
  transform-origin: 100% 0;
  transition: transform 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.hfx-curl-top-right:is(:hover, :focus-visible) {
  clip-path: polygon(0 0, calc(100% - 1.4em) 0, 100% 1.4em, 100% 100%, 0 100%);
}
.hfx-curl-top-right:is(:hover, :focus-visible)::before {
  transform: scale(1);
}

@media (prefers-reduced-motion: reduce) {
  .hfx-curl-top-right, .hfx-curl-top-right *, .hfx-curl-top-right::before, .hfx-curl-top-right::after, .hfx-curl-top-right *::before, .hfx-curl-top-right *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Customizing this snippet

  • Color: set --hfx-color on the element or a parent. Currently previewing #3b82f6.
  • Base size: set --hfx-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 16px.
  • Speed: change the duration on the transition or animation shorthand. Staggered delays are relative, so they keep their rhythm.
  • Reduced motion: the rule at the end of the CSS turns the motion off for people who asked their OS for less of it. Keep it.

Similar hover effects