TrollButton

A button that dodges the cursor until it runs out of stamina, then gives up and lets you click it.

Preview

Props

Install

npx shadcn@latest add @evilbuttons/troll-button

Usage

import TrollButton from "@/components/evil-buttons/troll-button";

export function ButtonDemo() {
  return (
    <TrollButton giveUpAfter={3000} onClick={() => console.log("Caught it")}>
      Click If You Can
    </TrollButton>
  );
}

Variants

Stubborn

A long chase over a wide area before it gives in.

Props

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

PropTypeDefaultDescription
childrenReact.ReactNode-Button label. Falls back to label.
labelReact.ReactNode"Click Me"Label used when no children are provided.
surrenderLabelReact.ReactNode"Fine, click me"Label shown once the button gives up.
giveUpAfternumber3500Milliseconds of chasing before it gives up. The timer starts on the first dodge.
fleeRadiusnumber56How close in px the cursor can get to the button's edge before it dodges.
rangenumber140Maximum distance in px it strays from its resting spot.
resetAfternumber1500Milliseconds after a successful click before it starts fleeing again. 0 keeps it caught.
onClick(event) => void-Only fires once the button has given up.
classNamestring-Extra classes passed to the button.

Good to know

  • On touch, taps make it dodge instead.
  • Keyboard clicks always go through.
  • prefers-reduced-motion turns the fleeing off.

Search docs

Jump to a button documentation page