AI CSS Animations

Round Corners Hover Effect

A square-cornered button softens into a pill on hover. Only border-radius transitions; it is set a touch past half the height so the ends end up fully round at any font size.

Also known as: hvr-round-corners, border radius transition, square to pill button.

HTML

<button class="hfx-round-corners">Sign up free</button>

CSS

.hfx-round-corners {
  --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;
  border-radius: 0;
  transition: border-radius 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);}
.hfx-round-corners:is(:hover, :focus-visible) {
  border-radius: 1.4em;
}

@media (prefers-reduced-motion: reduce) {
  .hfx-round-corners, .hfx-round-corners *, .hfx-round-corners::before, .hfx-round-corners::after, .hfx-round-corners *::before, .hfx-round-corners *::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-none bg-blue-500 px-6 py-3 font-semibold text-white transition-[border-radius] duration-300 ease-out hover:rounded-3xl focus-visible:rounded-3xl">
  Sign up free
</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