Spotlight
The default. A copy of the element flies out and grows. Nothing to do but read.
{ target, title, text }
The page pulls back, and each element you want to show flies out to the front of the screen. Or the camera moves onto the real element and the user has to use it to move on. Plain JavaScript, no dependencies.
Each card is a real element. Try it runs a one-step tour on it.
The default. A copy of the element flies out and grows. Nothing to do but read.
{ target, title, text }
The camera moves onto the element in place. For things styled by their parents, like a table row.
{ target, title, text, mode: 'real' }
| Voucher | Captured by |
|---|---|
| TR-1041 | Ana López |
| TR-1042 | Luis Pérez |
The user clicks the real element. Your app's own handler runs.
action: { type: 'click' }
The step is done once the field isn't empty. Arrow keys move the caret, not the tour.
action: { type: 'input' }
For selects, checkboxes, and radios: done when the value changes.
action: { type: 'change' }
Done when a condition holds, not on a raw event. The spotlight grows with the element.
action: { until: () => faq.open }
Anyone who can log in. Viewers are free.
The click counts, but the app never sees it. Teach the save button without saving.
action: { type: 'click', intercept: true }
From npm, or from a CDN with a <script> tag.
npm install spotlight-tour
<script src="https://unpkg.com/spotlight-tour@0.4/dist/index.umd.js"></script>
Create the tour once, give it steps, and start it. Steps with action are interactive.
import SpotlightTour from 'spotlight-tour';
const tour = new SpotlightTour({
steps: [
{ target: '#nav', title: 'Main navigation', text: 'Every section is here.' },
{
target: '#save',
title: 'Save your work',
text: 'Click it. Nothing is saved during the tour.',
action: { type: 'click', intercept: true },
},
],
});
tour.start();
onEnter can return a promise (a route change); the tour waits and then looks for the element.targetTimeout instead of leaving the user stuck.intercept on steps that save, and block writes in your HTTP client while tour.isActive.