AI CSS Animations

Outline to Solid Button

A ghost button that fills solid on hover. The plainest effect in the set, and the right default for secondary actions that should not shout.

Also known as: ghost button hover, secondary button fill.

HTML

<button class="hfx-outline-fill">Learn more</button>

CSS

.hfx-outline-fill {
  --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: 2px solid var(--c);
  background: transparent;
  color: var(--c);
  transition: background-color 0.2s ease, color 0.2s ease;}
.hfx-outline-fill:hover {
  background: var(--c);
  color: #fff;
}

@media (prefers-reduced-motion: reduce) {
  .hfx-outline-fill, .hfx-outline-fill *, .hfx-outline-fill::before, .hfx-outline-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="rounded-lg border-2 border-blue-500 px-6 py-3 font-semibold text-blue-500 transition duration-200 hover:bg-blue-500 hover:text-white">
  Learn more
</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