Plugins
Prompt
A plugin that asks the user for confirmation via an interactive UI before proceeding.
PromptPlugin
The PromptPlugin pauses the cursor execution to display an interactive prompt dialog near the virtual cursor. It waits for the user to select an option (such as confirming or canceling) before continuing the sequence. This is especially useful for staging realistic UI tests and demonstration narratives.
Demo
Options
Prop
Type
Method Signature
Prop
Type
Usage
import { Cursor, PromptPlugin } from '@cursor.js/core';
const cursor = new Cursor();
// Install the plugin
cursor.use(new PromptPlugin({
defaultPosition: 'cursor', // Display bubble by the cursor target
}));
// Use the .prompt() method within sequence
cursor
.hover('.delete-btn')
.prompt('Are you sure you want to delete this?', {
buttons: [
{ label: 'Yes', type: 'danger', onClick: 'continue' },
{ label: 'No', type: 'secondary', onClick: () => console.log('Cancelled!') }
]
})
.click('.delete-btn')
.wait(1000);Advanced Rendering
You can override the default styled buttons and render your own fully custom DOM by passing a render callback.
cursor
.hover('.target')
.prompt('Provide input', {
render: (container, resolve) => {
container.innerHTML = `
<input type="text" id="my-input" />
<button id="my-submit">Submit</button>
`;
// When resolved, cursor resumes.
container.querySelector('#my-submit').onclick = () => {
resolve(container.querySelector('#my-input').value);
}
}
})Positions
Like say(...), the prompt can be displayed in several distinct locations on the screen:
// 1. Follows the ghost cursor (Default)
cursor.prompt('Action required', { position: 'cursor' });
// 2. Fixed at the bottom center of the screen
cursor.prompt('Confirm below', { position: 'bottom' });
// 3. Absolute center of the viewport (Modal style)
cursor.prompt('Critical alert!', { position: 'center' });
// 4. Slightly elevated from the bottom (like movie subtitles)
cursor.prompt('Did you understand it?', { position: 'subtitle' });