AI CSS Animations

Hard Shadow Button

An outline button that lifts up and to the left on hover while a solid block shadow slides out behind it. No blur, just an offset box-shadow with a springy curve, for a printed, retro look.

Also known as: offset shadow hover, retro shadow button, outline to shadow button.

HTML

<button class="btn-hard-shadow">Download</button>

CSS

.btn-hard-shadow {
  --c: var(--btn-color, #3b82f6);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  font: 600 var(--btn-size, 18px)/1.2 system-ui, sans-serif;
  cursor: pointer;
  padding: 0.75em 1.7em;
  border: 2px solid var(--c);
  border-radius: 0.4em;
  background-color: transparent;
  color: var(--c);
  box-shadow: 0 0 0 var(--c);
  transition:
    transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
    background-color 0.3s ease;}
.btn-hard-shadow:is(:hover, :focus-visible) {
  transform: translate(-0.25em, -0.25em);
  background-color: color-mix(in srgb, var(--c) 10%, transparent);
  box-shadow: 0.3em 0.3em 0 var(--c);
}
.btn-hard-shadow:active {
  transform: translate(0, 0);
  box-shadow: 0 0 0 var(--c);
  transition-duration: 0.08s;
}

@media (prefers-reduced-motion: reduce) {
  .btn-hard-shadow, .btn-hard-shadow *, .btn-hard-shadow::before, .btn-hard-shadow::after, .btn-hard-shadow *::before, .btn-hard-shadow *::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-md border-2 border-blue-500 px-6 py-3 font-semibold text-blue-500 transition duration-300 hover:-translate-x-1 hover:-translate-y-1 hover:bg-blue-500/10 hover:shadow-[5px_5px_0_#3b82f6] active:translate-x-0 active:translate-y-0 active:shadow-none">
  Download
</button>

Customizing this snippet

  • Color: set --btn-color on the element or a parent. Currently previewing #3b82f6.
  • Base size: set --btn-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 18px.
  • 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 buttons