AI CSS Animations

Circle Fill Button

A circle grows from the center of an outlined button until it covers every corner. The circle is sized from the button's width, so short and long labels both fill completely.

Also known as: radial out button, expanding circle hover, circle grow button.

HTML

<button class="hfx-circle-fill">Get started</button>

CSS

.hfx-circle-fill {
  --c: var(--hfx-color, #3b82f6);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  padding: 0.75em 1.75em;
  border-radius: 0.5em;
  font: 600 var(--hfx-size, 16px)/1.2 system-ui, sans-serif;
  white-space: nowrap;
  cursor: pointer;
  border: 2px solid var(--c);
  background: transparent;
  color: var(--c);
  transition: color 0.3s ease 0.05s;
}
.hfx-circle-fill::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: -1;
  width: 120%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--c);
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.hfx-circle-fill:is(:hover, :focus-visible) {
  background-color: var(--c); /* hides the hairline where the fill meets the border */
  color: #fff;
  transition: color 0.3s ease 0.05s, background-color 0s 0.5s;
}
.hfx-circle-fill:is(:hover, :focus-visible)::before {
  transform: translate(-50%, -50%) scale(1);
}

@media (prefers-reduced-motion: reduce) {
  .hfx-circle-fill, .hfx-circle-fill *, .hfx-circle-fill::before, .hfx-circle-fill::after, .hfx-circle-fill *::before, .hfx-circle-fill *::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="group relative isolate overflow-hidden rounded-lg border-2 border-blue-500 px-7 py-3 font-semibold text-blue-500 transition-colors duration-300 hover:text-white">
  <span class="absolute left-1/2 top-1/2 -z-10 aspect-square w-[120%] -translate-x-1/2 -translate-y-1/2 scale-0 rounded-full bg-blue-500 transition-transform duration-500 ease-out group-hover:scale-100"></span>
  Get started
</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