Skip to content

NewMCP server for your coding agent. Set it up ›

Nexus UI
Get Pro

Runaway Button, animated React component

  • Pro
  • Inputs & Controls
  • Hover
  • Spring

A cancel-subscription dialog whose cancel button slips away from the pointer, getting less sure of itself each time, then gives up after a few tries and lets you click it. Keyboard users get a normal button that never moves while focused.

Props

PropTypeDefaultWhat it does
onCancelundefinedCalled when the cancel button is finally clicked or activated from the keyboard.
onKeepundefinedCalled when "Keep my plan" is clicked.
autoplayfalseHops the cancel button around the dialog every 1.1 s, until someone points at it, focuses it or presses a key.
dodgeRadius78How close in px the pointer can get to the button before it slips away. Clamped to 70 to 170.
maxDodges4How many times it dodges before it gives up and lets you click it. Clamped to 1 to 8.
speed1How fast it slides to its new spot. Higher is snappier. Clamped to 0.4 to 3.
wobble1How hard it wobbles each time it dodges. 0 turns the wobble off. Clamped to 0 to 2.5.

Add it to your project

  1. 1

    Set up your project once

    You need a Next.js project with Tailwind CSS and the @/ import alias. In its root folder, run this once. It creates components.json and the cn() helper in src/lib/utils.ts:

    npx shadcn@latest init -d

    Starting from nothing? The Quick Start walks through the whole thing.

  2. 2

    Connect the registry with your API key

    Runaway Button is a Pro item, so the CLI has to send your API key. Do this once per project:

    1. Create a key at nexus-ui.com/dashboard/api-key. Copy it straight away: it starts with nxs_ and is shown only once.
    2. In your project root, next to package.json, create a file named .env.local with this line, using your own key:
      NEXUS_API_KEY=nxs_your_key_here
    3. Open components.json and add this entry inside the outermost braces, next to "aliases". Leave {name} and ${NEXUS_API_KEY} exactly as written; the CLI fills them in:
      "registries": {
        "@nexus-labs": {
          "url": "https://www.nexus-ui.com/api/registry/{name}",
          "headers": {
            "Authorization": "Bearer ${NEXUS_API_KEY}"
          }
        }
      }

How Runaway Button works

Label for each try: it gets less sure of itself every time it runs.

The source, the install command and the build prompt come with Pro.

Runaway Button questions

How do I install Runaway Button?

Run `npx shadcn@latest add @nexus-labs/runaway-button`. It installs framer-motion. Runaway Button is a Pro component, so it needs a Pro plan and an API key; key setup is on the CLI docs page (/docs/cli).

How do I know when someone cancels or keeps the plan?

Pass `onCancel` for when the cancel button is finally clicked or activated from the keyboard, and `onKeep` for when "Keep my plan" is clicked. Both are optional and take no arguments.

How many times does the button dodge?

Four times (`MAX_TRIES`). Each time the pointer comes close it jumps to a new spot, and its label changes through the exported `RUNAWAY_LINES`, from "Yes, cancel" to "Okay, cancel". Then it settles back and can be clicked.

Is it usable without a mouse?

Yes. While the cancel button has keyboard focus it never moves, and Enter or Space activates it. After a keyboard choice, focus moves to the "Start over" button on the result screen.

Can I change the dialog text?

There are no text props. The heading, the body line and "Keep my plan" are written in the JSX, and the cancel labels come from the `RUNAWAY_LINES` array. Edit those in the source.