Runaway Button, animated React component
- Pro
- Inputs & Controls
- Hover
- Spring
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| onCancel | () => void | undefined | Called when the cancel button is finally clicked or activated from the keyboard. |
| onKeep | () => void | undefined | Called when "Keep my plan" is clicked. |
| autoplay | boolean | false | Hops the cancel button around the dialog every 1.1 s, until someone points at it, focuses it or presses a key. |
| dodgeRadius | number | 78 | How close in px the pointer can get to the button before it slips away. Clamped to 70 to 170. |
| maxDodges | number | 4 | How many times it dodges before it gives up and lets you click it. Clamped to 1 to 8. |
| speed | number | 1 | How fast it slides to its new spot. Higher is snappier. Clamped to 0.4 to 3. |
| wobble | number | 1 | How hard it wobbles each time it dodges. 0 turns the wobble off. Clamped to 0 to 2.5. |
Add it to your project
- 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 createscomponents.jsonand thecn()helper insrc/lib/utils.ts:npx shadcn@latest init -d
Starting from nothing? The Quick Start walks through the whole thing.
- 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:
- Create a key at nexus-ui.com/dashboard/api-key. Copy it straight away: it starts with
nxs_and is shown only once. - In your project root, next to
package.json, create a file named.env.localwith this line, using your own key:NEXUS_API_KEY=nxs_your_key_here
- Open
components.jsonand 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}" } } }
- Create a key at nexus-ui.com/dashboard/api-key. Copy it straight away: it starts with
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.

