Skip to the content

Button 01

A button that leans toward the pointer before the pointer reaches it, the label a little further than its plate, and settles back with a soft elastic return.

Create a free account to unlock it.

Sign up free

Already a member? Sign in

Documentation

  1. Copy to Webflow

    Add Geist and Geist Mono to your site's fonts (Site settings, Fonts, Google Fonts) before pasting: Webflow removes any font your site has not installed.

  2. Add custom CSS

    The look of the preview is the button-set-* classes of the paste: the button at rest, its row and the words around it. The Embed only holds the mechanics of the animation. On a button of your own, keep your class and add the attribute.
  3. Add custom JS

  4. Use it on your own elements

    Custom attribute
    Select the element on the canvas and open the Settings panel. Under Custom attributes, add a pair: the name on the left, the value on the right.
    Custom attributeWhat it does
    data-button-motion="magnetic" The button leans lightly toward the pointer before it reaches it, and settles back with a soft elastic return. Ignores a finger.
    This file plays magnetic. Another animation of the set needs that button's own code on the page: without it, the button stays as the page styled it and the browser console says so. An empty or unknown value plays fill when fill's code is on the page, magnetic otherwise, and says so in the console.
    Settings
    Every setting is a custom attribute too, added the same way and on the same element. An attribute always wins over the defaults written in the code.
    AttributeDefaultWhat it is
    data-button-motion-duration 0.6 The base length of the return, in seconds: once the pointer is out of reach the button settles back over 1.8 times this, with a soft elastic ease. The pull itself follows the pointer at its own pace.
    data-button-motion-pull 0.1 How far the button follows the pointer, as a share of the distance between the button's centre and the pointer.
    data-button-motion-reach 0.4 Where the pull begins, as a share of the button's height around its box.
    data-button-motion-press 0.96 The scale of the button while it is pressed.

What it does

Button 01 (Magnetic) is a button hover animation for Webflow and vanilla JavaScript, built on GSAP 3. Also called magnetic button.

A button that leans toward the pointer before the pointer reaches it, the label a little further than its plate, and settles back with a soft elastic return. Played with GSAP on the button the page already has: the engine sets no font, size, border or background, and puts the label back exactly on destroy. Keyboard focus and reduced motion are handled, and a finger is left alone. Button 01 of the Button set: another button of the set pasted on the same page shares its base. Pattern type magnetic button, magnetic cursor, cta hover.

Updated