StickyButton

Get this button for GPUI

A magnetic button whose body and label are pulled toward the cursor from a wide field, with parallax depth and tilt.

Preview

Props

Install

npx shadcn@latest add @evilbuttons/sticky

Usage

import StickyButton from "@/components/evil-buttons/sticky";

export function ButtonDemo() {
  return <StickyButton>Launch</StickyButton>;
}

Variants

Clingy

A wider field and a stronger pull make the button chase the cursor from far away.

Subtle

A tight field with no tilt, for a gentle magnetic nudge.

Props

The component spreads native button props and forwards its ref to the button.

PropTypeDefaultDescription
childrenReact.ReactNode-The button label or content.
radiusnumber120Distance in px beyond the button's edge where the pull starts.
strengthnumber0.45How far the body follows the cursor, as a fraction of the cursor offset.
parallaxnumber0.35How far the label drifts inside the body, from 0 (fixed to the body) to 1 (the edge of its padding).
tiltnumber8Maximum tilt in degrees while the body is pulled.
classNamestring-Extra classes passed to the button.

Good to know

  • The pull fades smoothly to zero at the field's edge.
  • Runs on motion values, with no re-renders on pointer move.

Search docs

Jump to a button documentation page