Popover
Every step and highlight can show a popover next to its element. This page covers where it sits and which buttons it has. To change how it looks, see Theming.
Position
side picks the side of the element the popover sits on: "top", "right", "bottom" (default) or "left". align places it along that side: "start" (default), "center" or "end".
import { driver } from "driver.js";
import "driver.js/dist/driver.css";
const driverObj = driver();
driverObj.highlight({
element: "#sample-box",
popover: {
title: "Left Start",
description: "On the left, aligned with the top edge.",
side: "left",
align: "start",
},
});
Use the buttons below to show the popover.
When the popover doesn’t fit on that side, it moves to one where it does. Scroll the box near an edge of the window and try again.
Buttons
showButtons picks the buttons: "next", "previous" and "close". A tour shows all three by default. Set it on the driver for every step, or on a step’s popover.
disableButtonstakes the same values and shows the button greyed out. Previous is disabled on the first step.- The arrow keys follow the buttons: they do nothing when their button is hidden or disabled. Escape does nothing when the close button is disabled.
highlight()shows no buttons by default. Outside a tour, Next and Previous only do something if you setonNextClickandonPrevClick.- A step with
popover.instructionkeeps the Next button but shows it disabled until the user has done it.
Change Button Text
nextBtnText, prevBtnText and doneBtnText set the button text, and HTML is allowed. closeBtnLabel sets the screen reader label of the close button.
Event Handlers
onNextClick, onPrevClick, onCloseClick and onDoneClick run instead of the button’s default action. The tour then only moves or ends when you call moveNext(), movePrevious() or destroy(). Set them on the driver for every step, or on a step’s popover.
onDoneClick runs on the last step instead of onNextClick, so it tells you the user finished the tour.
import { driver } from "driver.js";
import "driver.js/dist/driver.css";
const driverObj = driver({
steps: [
// ...
],
onNextClick: () => {
console.log("Next clicked");
driverObj.moveNext();
},
onPrevClick: () => {
console.log("Previous clicked");
driverObj.movePrevious();
},
onCloseClick: () => {
console.log("Close clicked");
driverObj.destroy();
},
onDoneClick: () => {
console.log("Done clicked");
driverObj.destroy();
},
});
driverObj.drive();onNextClick also runs when the step is completed another way: the right arrow key, an overlay click with overlayClickBehavior: "nextStep", advanceOn or advance(). For loading something before the next step, see Wait for a Save.
To add your own buttons, like Skip or Restart, or translate the built-in ones, see Custom Buttons.
driver.js