Skip to content
/ghost-cursor

A cursor that demos your component, then gets out of the way.

Writing
  • Springs, not curves1,240 reads
  • The cost of a hover3,810 reads
  • Ghosts in the DOM2,275 reads
  • A menu, slowly960 reads
0.0s
The real menu, replaying a take I recorded by hand. Move into the box and it’s yours. Leave, and the ghost carries on.
Tell your agent
Read https://ghost-cursor.muratalpay.me/docs and record this component’s interaction.

Name the component and what it should do, or ask it to open the record toolbar instead. The agent reads the steps from the docs for agents, records a take, checks that it replays, and gives you the snippet.

Or do it yourself

ghost-cursor dispatches real pointer and keyboard events, so nothing inside your component knows it’s being replayed.

Step 1: Install

npm installs Motion alongside it as a peer dependency. Motion drives the cursor’s spring.

npm i @imuratalpay/ghost-cursor
/* app/globals.css */
@import "tailwindcss";
@import "@imuratalpay/ghost-cursor/styles.css" layer(components);

Step 2: Wrap

Give the box a height, and put data-ghost-id on every element the cursor clicks. The recording finds elements by that name, so it keeps working when the markup around them changes.

import { GhostReplay } from "@imuratalpay/ghost-cursor";
import take from "./sort-menu.json";
<GhostReplay recording={take} style={{ height: 320 }}>
  <SortMenu />
</GhostReplay>

Step 3: Record

In development, ?record turns every demo on the page into a recorder.

npm run dev
# open http://localhost:3000/your-post?record
# press Record, then use the component
# press Stop, then Copy recording
# paste the JSON into sort-menu.json

The docs cover recording, the agent skill, every prop, and four more examples.