Feature Hints

Hints are pulsing beacons that sit on the page. The user clicks one to open a popover, in any order. Nothing is blocked, so the page stays usable.

They are a separate entry with their own stylesheet. You don’t need driver.css unless you also use tours.

import { hints } from "driver.js/hints";
import "driver.js/dist/hints.css";

Each hint points at an element and describes it in a popover. The demo also turns on the optional overlay.

Quarterly Report

Revenue is up 12% quarter over quarter. Click the beacons to explore what changed. The page stays fully interactive while they are shown.

const productHints = hints({
  overlay: true,
  overlayOpacity: 0.5,
  hints: [
    {
      element: "#export-btn",
      id: "export",
      popover: {
        title: "Export your data",
        description: "Download this report as CSV or PDF.",
      },
    },
    {
      element: "#summary",
      id: "summary",
      beacon: { side: "left", align: "center" },
      popover: {
        title: "Auto-generated summary",
        description: "Written for you from the quarter's numbers.",
        side: "bottom",
      },
    },
  ],
});

productHints.show();

Closing vs. dismissing

  • Closing keeps the beacon. Clicking the beacon again, clicking outside or pressing Escape closes the popover, and the hint can be opened again.
  • Dismissing removes the beacon. The Got it button does it and runs onDismiss. Set onButtonClick to decide yourself what the button does.

Only one hint is open at a time.

Remembering dismissals

Dismissals last until the page reloads. To keep them, give hints an id and save it in onDismiss. Dismiss a hint below, then load the page again.

Q3 report
Dismissed: none

Dimming the page

overlay: true dims the page while a hint is open, like a tour step. The element is cut out and stays usable, the popover points at the element instead of the beacon, and a click on the dimmed page closes the hint.

const productHints = hints({
  overlay: true,
  overlayColor: "#000",
  overlayOpacity: 0.5,
  hints: [
    // ...
  ],
});

Using hints alongside a tour

While a tour runs, the beacons hide. They come back when it ends. A hint can also start a tour from its button. Open the beacon below and take the tour.

1,204 visits

For more buttons or your own markup, use onPopoverRender, like in tours.

Styling

Beacon placement

A beacon sits on an edge of its element: side picks the edge and align the position along it. The default is the top right corner. offsetX and offsetY move it by a number of pixels, where positive is right and down.

const productHints = hints({
  hints: [
    {
      element: "#dashboard",
      beacon: { side: "top", align: "end", offsetX: -12, offsetY: 8 },
      popover: { title: "Dashboard" },
    },
  ],
});

Beacon color and size

Beacons read CSS variables for their color and size. Set them on .driver-hint for all beacons, or on a class you give one beacon with className. All beacon variables and classes are in Theming.

Quarterly Report

Revenue is up 12% quarter over quarter. Click the beacons to explore what changed. The page stays fully interactive while they are shown.

/* All beacons */
.driver-hint {
  --driver-hint-color: #e11d48;
  --driver-hint-size: 28px;
}

/* Only beacons carrying a class */
.my-special-hint {
  --driver-hint-color: #059669;
}
const productHints = hints({
  hints: [
    {
      element: "#export-btn",
      beacon: { className: "my-special-hint" },
      popover: { title: "A green beacon" },
    },
  ],
});

Static beacons

animate: false turns the pulse off. Users who prefer reduced motion never see it.

Quarterly Report

Revenue is up 12% quarter over quarter. Click the beacons to explore what changed. The page stays fully interactive while they are shown.

const productHints = hints({
  // For every hint. A hint's own beacon values win.
  beacon: { animate: false },
  hints: [
    // ...
  ],
});

Custom button text

buttonText changes the Got it button, for all hints or in one hint’s popover. showButton: false hides it, for hints you dismiss from code.

Quarterly Report

Revenue is up 12% quarter over quarter. Click the beacons to explore what changed. The page stays fully interactive while they are shown.

const productHints = hints({
  buttonText: "Thanks, understood",
  hints: [
    {
      element: "#share-btn",
      popover: {
        title: "No button at all",
        showButton: false,
      },
    },
  ],
});

Theming the popover

Hint popovers are regular popovers, so popoverClass and everything in Theming apply.

Quarterly Report

Revenue is up 12% quarter over quarter. Click the beacons to explore what changed. The page stays fully interactive while they are shown.

const productHints = hints({
  popoverClass: "driverjs-theme",
  hints: [
    // ...
  ],
});

Reference