AI CSS Animations

Grow Rotate Hover Effect

A coupon chip that grows and tips a few degrees on hover, on a spring curve that overshoots and settles. The dashed inner line is an outline with a negative offset, so it needs no extra markup.

Also known as: hvr-grow-rotate, rotate and scale on hover, tilt button hover css.

HTML

<button class="hfx-grow-rotate">Save 20%</button>

CSS

.hfx-grow-rotate {
  --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;
  padding: 0.75em 1.5em;
  outline: 1px dashed rgb(255 255 255 / 0.7);
  outline-offset: -0.4em;
  letter-spacing: 0.02em;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);}
.hfx-grow-rotate:is(:hover, :focus-visible) {
  transform: scale(1.1) rotate(4deg);
}

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

Tailwind CSS version

The same effect using Tailwind utility classes. No custom CSS or config needed.

<button class="rounded-lg bg-blue-500 px-6 py-3 font-semibold text-white outline-dashed outline-1 outline-offset-[-6px] outline-white/70 transition-transform duration-300 ease-[cubic-bezier(0.34,1.56,0.64,1)] hover:rotate-3 hover:scale-110">
  Save 20%
</button>

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