AI CSS Animations

Lift Button

The most common button hover on the web: the button lifts a few pixels and gains a shadow, as if it floated off the page. Subtle, fast and safe for any brand.

Also known as: raise on hover, elevate button, hover shadow.

HTML

<button class="hfx-lift">Add to cart</button>

CSS

.hfx-lift {
  --c: var(--hfx-color, #3b82f6);
  font-size: var(--hfx-size, 16px);
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.7em 1.6em;
  border-radius: 0.5em;
  font: 600 1em system-ui, sans-serif;
  cursor: pointer;
  border: 0;
  background: var(--c);
  color: #fff;
  transition: transform 0.2s ease, box-shadow 0.2s ease;}
.hfx-lift:hover {
  transform: translateY(-3px);
  box-shadow: 0 0.6em 1.2em color-mix(in srgb, var(--c) 35%, transparent);
}
.hfx-lift:active {
  transform: translateY(-1px);
  box-shadow: 0 0.3em 0.6em color-mix(in srgb, var(--c) 35%, transparent);
}

@media (prefers-reduced-motion: reduce) {
  .hfx-lift, .hfx-lift *, .hfx-lift::before, .hfx-lift::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 transition duration-200 hover:-translate-y-0.5 hover:shadow-lg hover:shadow-blue-500/30 active:translate-y-0">
  Add to cart
</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