Skip to content
HomeExamplesContextual hints

Hints · Practical

Introduce features with contextual hints

Add unobtrusive hint markers to useful features, open their popovers and remember which tips a visitor has dismissed.

sitetourkit 0.7.1createHints · rememberDismissed

Loading the interactive example…

Make it yours

Download HTML
import { createHints } from "sitetourkit/hints";
import "sitetourkit/styles.css";
const KEY = "sitetourkit:examples:contextual-hints:v1";
let hints;
const status = document.querySelector("#demo-status");
document.querySelector("#run-demo").onclick = () => {
    hints?.destroy();
    hints = createHints({
        rememberDismissed: { key: KEY, storage: "local" },
        hints: [
            {
                id: "search",
                target: "#hint-search",
                content: "Find pages, reports and teammates in one place.",
                placement: "bottom",
            },
            {
                id: "export",
                target: "#hint-export",
                content: "Export a report whenever you need an offline copy.",
                placement: "top",
            },
            {
                id: "share",
                target: "#hint-share",
                content: "Share this view with someone on your team.",
                placement: "top",
            },
        ],
    }).render();
    hints.on("dismiss", () => {
        status.textContent = "Hint dismissed. It stays hidden until you reset the example.";
    });
    status.textContent = "Hints are ready. Select a green marker to open a tip.";
};
document.querySelector("#reset-demo").onclick = () => {
    hints?.destroy();
    localStorage.removeItem(KEY);
    status.textContent = "Hints reset. Select Run example to show all three again.";
};
window.addEventListener("pagehide", () => hints?.destroy());
Install sitetourkit, then use this with the example markup.

Helpful tips, at the user's pace ​

Hints attach small markers to individual features. Select Run example, then open a green marker to learn about search, exports or sharing. Dismissing a tip remembers that choice, so running the example again keeps it hidden.

Select Reset to clear the remembered dismissals for this example and show all three tips again.

Load the hints entry point ​

Import createHints from sitetourkit/hints and include the shared stylesheet. Each hint has a stable id, a target and its content. Call render() to mount the markers.

rememberDismissed uses a key chosen by the host application. This example uses a dedicated key so resetting it does not remove any other site's state.

Choose hints for optional discovery ​

  • Use a guided tour when there is a sequence the user should follow.
  • Use hints for independent features that can be explored in any order.
  • Keep hint IDs stable when rearranging the list.
  • Call destroy() when removing the interface that owns the hints.