AI CSS Animations

Expanding Circle Arrow Button

The 'Learn more' pattern: a colored circle holding an arrow stretches into a full pill behind the label, the text turns white and the arrow steps forward. One element changes width.

Also known as: learn more button hover, circle to pill button, arrow circle button.

HTML

<button class="btn-circle-arrow-expand">
  <span class="btn-circle-arrow-expand-circle" aria-hidden="true">
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M4 12h15M13 6l6 6-6 6"/></svg>
  </span>
  <span class="btn-circle-arrow-expand-label">Learn more</span>
</button>

CSS

.btn-circle-arrow-expand {
  --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;
  position: relative;
  width: 11.5em;
  height: 3em;
  padding: 0;
  border: 0;
  background: transparent;}
.btn-circle-arrow-expand-circle {
  position: absolute;
  inset: 0 auto 0 0;
  width: 3em;
  border-radius: 1.5em;
  background: var(--c);
  transition: width 0.45s cubic-bezier(0.65, 0, 0.076, 1);
}
.btn-circle-arrow-expand-circle svg {
  position: absolute;
  top: 50%;
  left: 0.8em;
  width: 1.4em;
  height: 1.4em;
  margin-top: -0.7em;
  color: #fff;
  transition: transform 0.45s cubic-bezier(0.65, 0, 0.076, 1);
}
.btn-circle-arrow-expand-label {
  position: relative;
  flex: 1;
  padding-left: 2.6em;
  color: var(--c);
  text-align: center;
  transition: color 0.45s cubic-bezier(0.65, 0, 0.076, 1);
}
.btn-circle-arrow-expand:is(:hover, :focus-visible) .btn-circle-arrow-expand-circle { width: 100%; }
.btn-circle-arrow-expand:is(:hover, :focus-visible) .btn-circle-arrow-expand-circle svg { transform: translateX(0.45em); }
.btn-circle-arrow-expand:is(:hover, :focus-visible) .btn-circle-arrow-expand-label { color: #fff; }

@media (prefers-reduced-motion: reduce) {
  .btn-circle-arrow-expand, .btn-circle-arrow-expand *, .btn-circle-arrow-expand::before, .btn-circle-arrow-expand::after, .btn-circle-arrow-expand *::before, .btn-circle-arrow-expand *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

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