Skip to content
motionprompts motionprompts

Block Button Roll Fill

GSAP animation component · Published 2026-11-21 · by vanguardia.dev

Open live demo ↗ Raw prompt (.md)

What it does

Tall 100px block buttons with an uppercase label at the bottom left and a round arrow badge at the top right. On hover an accent fill rises from the bottom (scaleY), the label rolls up and its twin takes its place, and the arrow turns 45 degrees; dark and light variants. A subtle magnetic pull follows the pointer with gsap.quickTo, on fine pointers only.

How it's built

Categoryhover
Techgsap
Complexitywidget
Performance costlight
Mobile-safeyes

button cta hover fill roll text-swap magnetic quickTo arrow

Rebuild it with AI

To reproduce this animation in your own project, copy the prompt below into Claude Code, Cursor or any AI coding agent. The prompt is validated, it describes the exact structure, timing and easing, so the agent rebuilds the effect faithfully and you can then adapt colors, copy and layout to your design.

The full prompt

Block Button Roll Fill: Tall Block Buttons With Rising Fill, Rolling Label and Magnetic Pull

Goal

Build a white full-viewport section with three "block" buttons centred in a wrapping row: each is a 100px tall box, at least 220px wide, with an uppercase label at the bottom left and a small round badge with a diagonal arrow at the top right. On hover (and keyboard focus) an accent fill rises from the bottom (scaleY 0 to 1), the label rolls up and its twin rolls in from below to replace it, and the arrow turns 45°. Two dark buttons and one light one (white with a hairline). With a fine pointer each button is gently pulled toward the cursor with gsap.quickTo.

Tech

Vanilla HTML/CSS/JS with ES module imports. gsap (npm), no plugins; the hover itself is pure CSS. Font: Inter 600.

Layout / HTML

<div class="bb">
  <section class="bb-stage">
    <a class="bb-btn" href="#" data-bb-magnet>
      <span class="bb-txt"><span>Get started</span><span aria-hidden="true">Get started</span></span>
      <span class="bb-ico"><svg viewBox="0 0 10 10" aria-hidden="true"><path d="M2 8 8 2M3.5 2H8v4.5" fill="none" stroke="currentColor" stroke-width="1.4"/></svg></span>
    </a>
    <a class="bb-btn bb-btn--light" href="#" data-bb-magnet>… Contact …</a>
    <a class="bb-btn" href="#" data-bb-magnet>… View work …</a>
  </section>
</div>

Styling

:root: --bb-bg:#fff, --bb-dark:#111, --bb-light:#fff, --bb-line:#e2e2e2, --bb-accent:#c2185b, --bb-radius:6px, --bb-ease:cubic-bezier(.19,1,.22,1).

  • .bb-stage: min-height:100svh; display:flex; flex-wrap:wrap; align-items:center; justify-content:center; align-content:center; gap:24px; padding:40px 16px.
  • .bb-btn: position:relative; display:flex; align-items:flex-end; justify-content:space-between; gap:16px; min-width:220px; height:100px; padding:12px 10px 12px 12px; border-radius:var(--bb-radius); background:var(--bb-dark); color:var(--bb-light); font-size:15px; font-weight:600; text-transform:uppercase; letter-spacing:.01em; overflow:hidden; isolation:isolate.
  • Fill: .bb-btn::before { content:""; position:absolute; inset:0; background:var(--bb-accent); z-index:-1; transform:scaleY(0); transform-origin:50% 100%; transition:transform .6s var(--bb-ease) }, :hover/:focus-visible → scaleY(1).
  • Label: .bb-txt { display:grid; overflow:hidden; height:1.15em; line-height:1.15 }, both spans in grid-area:1/1 with transition:transform .6s var(--bb-ease); the second starts at translateY(110%). On hover the first goes to -110%, the second to 0.
  • Badge: .bb-ico { align-self:flex-start; 20px circle; background:var(--bb-light); color:var(--bb-dark) }, rotate(45deg) on hover, svg 10px.
  • Light variant: background:var(--bb-light); color:var(--bb-dark); box-shadow:inset 0 0 0 1px var(--bb-line); badge inverted (dark circle, white arrow); on hover text turns white and the badge goes white with an accent arrow.
  • Reduced motion: transition durations to .01ms.

GSAP effect (be exact)

const DEFAULTS = { magnet: .25, duration: .6 };

Only if (pointer: fine) matches and reduced motion does not: per button xTo = gsap.quickTo(el, "x", { duration:.6, ease:"power3.out" }), same for y. On pointermove: measure the rect, subtract the current gsap.getProperty(el,"x"|"y") to get the resting centre, then xTo((clientX - cx) * magnet), yTo((clientY - cy) * magnet). On pointerleave: xTo(0); yTo(0).

destroy(): remove listeners, killTweensOf the buttons, clearProps:"transform".

Assets / images

None.

Behavior notes

  • The duplicated label is aria-hidden, so screen readers hear it once.
  • :focus-visible gets the same state as hover, so keyboard users see the fill.
  • Only the prefixed variables are global.

Using this outside its demo page

This component is written as a complete page: that is how the demo is meant to look. If you are dropping it into an existing project, or combining it with other components, these are the things it declares at document level and that you need to move or reconcile first.

  • Palette on :root: --bb-bg, --bb-dark, --bb-light, --bb-line, --bb-accent, --bb-radius, --bb-ease. Generic names like --ink, --paper or --muted are defined by many components in this catalogue with different values, and they will also collide with whatever your own project defines. Move them onto the component's wrapper (.my-section { --ink: … }) or keep the prefix.
  • **Rules on *, *::before, *::after, html, body**: the demo owns the whole document, so these set the box model and resets. Dropped into an existing project they restyle the entire page, not just this section. Re-target them at the component's wrapper before using it.

New components in your inbox

One email a week, only when new components ship, each with its live demo and prompt.