Theming
Driver.js is styled with plain CSS. Override its classes, set its CSS variables, or change the popover’s DOM in a hook.
Popover
Give the popover your own class with popoverClass, then style it. Set it on the driver for every popover, or on a step’s popover for one.
import { driver } from "driver.js";
import "driver.js/dist/driver.css";
const driverObj = driver({
popoverClass: "driverjs-theme",
steps: [
// ...
],
});
driverObj.drive();.driver-popover.driverjs-theme {
background-color: #fde047;
color: #000;
}
.driver-popover.driverjs-theme .driver-popover-title {
font-size: 20px;
}
.driver-popover.driverjs-theme .driver-popover-title,
.driver-popover.driverjs-theme .driver-popover-description,
.driver-popover.driverjs-theme .driver-popover-progress-text {
color: #000;
}
.driver-popover.driverjs-theme button:not(.driver-popover-close-btn) {
flex: 1;
text-align: center;
background-color: #000;
color: #fff;
border: 2px solid #000;
text-shadow: none;
font-size: 14px;
padding: 5px 8px;
border-radius: 6px;
}
.driver-popover.driverjs-theme .driver-popover-navigation-btns {
justify-content: space-between;
gap: 3px;
}
.driver-popover.driverjs-theme .driver-popover-close-btn {
color: #9b9b9b;
}
.driver-popover.driverjs-theme .driver-popover-close-btn:hover {
color: #000;
}
/* The arrow is a border, one rule per side */
.driver-popover.driverjs-theme .driver-popover-arrow-side-left {
border-left-color: #fde047;
}
.driver-popover.driverjs-theme .driver-popover-arrow-side-right {
border-right-color: #fde047;
}
.driver-popover.driverjs-theme .driver-popover-arrow-side-top {
border-top-color: #fde047;
}
.driver-popover.driverjs-theme .driver-popover-arrow-side-bottom {
border-bottom-color: #fde047;
}
Popover Classes
.driver-popover {} /* The popover */
.driver-popover-arrow {} /* The arrow pointing at the element */
.driver-popover-arrow-side-top {} /* Named after the popover's side */
.driver-popover-arrow-none {} /* Hidden: popover centered or over */
.driver-popover-title {}
.driver-popover-description {}
.driver-popover-close-btn {} /* The close button, top right */
.driver-popover-footer {} /* Progress text and buttons */
.driver-popover-progress-text {}
.driver-popover-navigation-btns {} /* Holds the buttons */
.driver-popover-footer-btn {} /* Button look. Add it to yours too */
.driver-popover-prev-btn {}
.driver-popover-next-btn {}
.driver-popover-done-btn {} /* Next, on the last step */
.driver-popover-btn-disabled {} /* On a disabled button */
/* Where the popover ended up, after flipping to fit the screen */
.driver-popover-side-top {} /* or -right, -bottom, -left */
.driver-popover-align-start {} /* or -center, -end */
/* Action steps */
.driver-popover-has-instruction {} /* On the popover of an action step */
.driver-popover-instruction {} /* The instruction row */
.driver-popover-instruction-text {} /* Its text */
/* The dot at its end; a check mark once done */
.driver-popover-instruction-indicator {}
/* On the popover while it pauses for advanceDelay */
.driver-popover-instruction-done {}
/* Next, while the step waits for the user */
.driver-popover-btn-disabled[aria-disabled] {}
.driver-popover-feedback {} /* The line shown by nudge("...") */
/* States */
.driver-popover-waiting {} /* While it waits for an element */
.driver-popover-nudge {} /* While nudge() shakes it */
The popover also has the id driver-popover-content, which the highlighted element’s aria-controls points to.
Animations use these keyframes, so you can swap one by setting animation on the class that runs it: driver-nudge-shake on .driver-popover-nudge, driver-nudge-flash in its place with reduced motion, and driver-instruction-pulse on .driver-popover-instruction-indicator.
CSS Variables
Set them on :root, or on your popoverClass to scope them.
:root {
/* Font of the popover, and of checklists */
--driver-popover-font-family: "Inter", sans-serif;
/* Action steps: the instruction row */
--driver-instruction-background: #f2f2f2;
--driver-instruction-color: inherit;
--driver-instruction-padding: 8px 10px;
--driver-instruction-radius: 4px;
/* Action steps: the dot at the end of the row, and the disabled Next */
--driver-instruction-indicator-color: #f59e0b;
--driver-instruction-indicator-size: 8px;
--driver-instruction-next-color: #a3a3a3;
/* Action steps: the done state, for the row, the check mark and Next */
--driver-instruction-done-background: #dcfce7;
--driver-instruction-done-color: #15803d;
/* The line shown by nudge("...") */
--driver-feedback-color: #b45309;
/* The shake of nudge(), and the flash shown with reduced motion */
--driver-nudge-distance: 6px;
--driver-nudge-duration: 500ms;
--driver-nudge-color: #f59e0b;
/* Read-only: set from the duration option while a tour runs, for
your own transitions to match */
--driver-animation-duration: 400ms;
/* Stacking of allowedElements above the overlay */
--driver-allowed-z-index: 10001;
/* The highlighted element inside an allowed element, like an item in an
open menu: a ring and a tint instead of the cutout */
--driver-raised-highlight-color: #2563eb;
--driver-raised-highlight-width: 2px;
--driver-raised-highlight-offset: -2px;
--driver-raised-highlight-background: rgb(37 99 235 / 0.1);
}
The values above are the defaults, except the font. Its default is:
"Helvetica Neue", Inter, ui-sans-serif, "Apple Color Emoji", Helvetica,
Arial, sans-serif;
Action Steps
An action step shows an instruction row that ends in a pulsing dot, and a Next button that looks disabled until the user has done it. While the step pauses for advanceDelay the dot becomes a check mark and the row and Next turn green. The dot and the check are drawn in CSS, don’t animate with prefers-reduced-motion, and are hidden from screen readers. The variables cover the colors and sizes, and the classes the rest.
const driverObj = driver({
popoverClass: "my-theme",
showButtons: ["next", "close"],
steps: [
{
element: "#publish",
advanceOn: "click",
advanceDelay: 1200,
popover: {
title: "Publish the page",
instruction: "Click <b>Publish</b>.",
},
},
// ...
],
});
driverObj.drive();.my-theme {
--driver-instruction-background: #eef2ff;
--driver-instruction-color: #3730a3;
--driver-instruction-radius: 999px;
--driver-instruction-padding: 8px 14px;
--driver-instruction-indicator-color: #6366f1;
--driver-instruction-indicator-size: 10px;
--driver-instruction-done-background: #dcfce7;
--driver-instruction-done-color: #166534;
}
.my-theme.driver-popover-instruction-done .driver-popover-instruction {
font-weight: 600;
}
To drop the dot and the check, hide the indicator. To change the row altogether, replace the content of popover.instruction in onPopoverRender; driver.js leaves it alone from then on. popover.instructionIndicator is the dot itself.
.driver-popover-instruction-indicator {
display: none;
}
Changing the Popover DOM
onPopoverRender gets the popover’s elements before it shows. Add, move or change anything. See Custom Buttons for a live example.
type PopoverDOM = {
wrapper: HTMLElement;
arrow: HTMLElement;
title: HTMLElement;
description: HTMLElement;
footer: HTMLElement;
progress: HTMLElement;
previousButton: HTMLButtonElement;
nextButton: HTMLButtonElement;
closeButton: HTMLButtonElement;
footerButtons: HTMLElement;
// Only on steps with popover.instruction: the row, and the indicator at
// its end.
instruction?: HTMLElement;
instructionIndicator?: HTMLElement;
// Only after nudge("...") showed a message
feedback?: HTMLElement;
};
const driverObj = driver({
onPopoverRender: popover => {
const link = document.createElement("a");
link.href = "/help/tours";
link.textContent = "Learn more";
popover.description.append(" ", link);
},
});
Overlay
overlayColor takes any CSS color and overlayOpacity a number from 0 to 1. The defaults are "#000" and 0.7.
const driverObj = driver({
overlayColor: "red",
overlayOpacity: 0.3,
});
driverObj.highlight({
popover: { title: "A red overlay", description: "Any CSS color works." },
});
stagePadding and stageRadius set the size and corner radius of the cutout around the element.
Page and Element Classes
/* On <body> while a tour or highlight is showing */
.driver-active {}
.driver-fade {} /* With animate: true */
.driver-simple {} /* With animate: false */
.driver-no-scroll {} /* With allowScroll: false */
.driver-overlay {} /* The overlay, an <svg> */
.driver-active-element {} /* The highlighted element */
.driver-allowed-element {} /* Each of the allowedElements */
.driver-active-element-raised {} /* ...inside an allowed element */
.driver-no-interaction {} /* With disableActiveInteraction: true */
/* The highlighted element's parent, and if it scrolls, -no-scroll too,
which stops it scrolling during the step */
.driver-active-element-parent {}
.driver-active-element-parent-no-scroll {}
Classes not listed on this page, like the ones driver.js uses to position layers or announce steps to screen readers, are internal and may change.
Hints
Hint popovers are regular popovers with an extra driver-hint-popover class, so everything above applies. The beacons read these variables, set on .driver-hint or on a class you pass as beacon.className. The values are the defaults:
.driver-hint {
--driver-hint-size: 24px;
--driver-hint-color: #818cf8;
--driver-hint-animation-duration: 2s; /* One pulse */
}
.driver-hint {} /* The beacon, a <button> */
.driver-hint-dot {} /* Its dot */
.driver-hint-pulse {} /* The pulsing ring (driver-hint-pulse) */
.driver-hint-hidden {} /* While its element is scrolled out of view */
.driver-hint-popover {} /* On the popover, next to .driver-popover */
.driver-hint-overlay {} /* The dimmed page, with overlay: true */
See Styling Hints for live examples.
Checklist
Checklists have their own stylesheet and classes.
Accent Color
--driver-checklist-color colors the progress bar, the ticks and the focus rings.
:root {
--driver-checklist-color: #16a34a;
}
Custom Theme
Pass className to put your own class on the widget, then style its parts. This is the theme of the driver.js homepage:
checklist({
id: "onboarding",
className: "checklist-brutalist",
items,
});
Its CSS, and more themes to copy, are on the Checklist Themes page.
Checklist Classes
.driver-checklist {} /* The widget, in a corner */
.driver-checklist-bottom-right {} /* or -bottom-left, -top-right… */
.driver-checklist-no-launcher {} /* With launcher: false */
.driver-checklist-complete {} /* Added once every item is done */
.driver-checklist-launcher {} /* The button that opens the panel */
.driver-checklist-launcher-text {}
.driver-checklist-launcher-count {} /* "1/4" */
.driver-checklist-panel {}
.driver-checklist-header {}
.driver-checklist-title {}
.driver-checklist-description {}
.driver-checklist-close-btn {}
.driver-checklist-progress {}
.driver-checklist-progress-bar {}
.driver-checklist-progress-fill {}
.driver-checklist-progress-text {} /* "1 of 4" */
.driver-checklist-items {}
.driver-checklist-item {}
.driver-checklist-item-done {} /* Once the item is done */
.driver-checklist-check {} /* The circle */
.driver-checklist-item-trigger {} /* Its link, button or row */
.driver-checklist-item-title {}
.driver-checklist-item-description {}
The widget also reads these variables:
.driver-checklist {
/* Distance from the screen edges. Defaults: 20px, 12px on phones */
--driver-checklist-offset-x: 20px;
--driver-checklist-offset-y: 20px;
}
The offset option sets them for you. The panel opens with the driver-checklist-in keyframes, or driver-checklist-in-down at the top corners.
It sets --driver-checklist-progress to the progress as a percentage, for progress drawn in CSS like the progress ring. The font follows --driver-popover-font-family.
driver.js