About this article
This article is created using an automated generation workflow leveraging generative AI. We verified tour steps, start/end, keyboard operations, and licenses using the official Driver.js 1.3.6 source, and inspected demo syntax and wiring with Node.js. Screen rendering on GitHub Pages and real browser operations have not been verified in this environment.Verification Status: 🧪 JavaScript syntax and demo wiring verified / Live screen and real browser operations unverified
On first-time screens, guiding button locations one by one reduces confusion. However, tours can cover the screen and restrict operations. To make them user-friendly, design not only the 'order of explanations' but also 'whether users can close them at any time to return to normal operations.' Here, we test a two-stage search and save tour with Driver.js and observe the differences when changing inputs and exit methods.
- What to try in this article
- Supported Environments and Constraints
- Operating the demo
- How it works: Pairing elements and descriptions
- What you learn by changing conditions
- Closing methods and keyboard operation
- When things do not work
- Things to decide before using in production
- Learning Materials and Verification
- Source
What to try in this article
Driver.js is a JavaScript library that sequentially highlights elements on the screen and explains them using tooltips. It can be used for initial setups, complex search conditions, and application form guidance.
In this tutorial, we create a tour targeting the search and save buttons. There is no functionality to actually search or save data; you will only experience the guidance mechanism by changing headings.
Supported Environments and Constraints
| Item | Content |
|---|---|
| Target Library | Driver.js 1.3.6. Version fixed for the tutorial |
| Operating Environment | Current browsers capable of executing JavaScript and CSS |
| Required Network Access | Fetch Driver.js and CSS from CDN. External libraries are also used for diagram rendering |
| Input | Fictional screen name. Leave blank for "Record", maximum 20 characters for display |
| Output | A two-step tour guiding the search and save buttons |
| Out of scope for this demo | Actual searching, saving, server communication, and persistence of input values |
| Unverified | Live page rendering, browser manipulation, screen readers, mobile devices, and focus restoration |
Driver.js 1.3.6 is licensed under the MIT License. The versions and licenses of the libraries used can be checked in theofficial package.jsonand theofficial licenses.
Operating the demo
Open the live demo above.
Type "Record" into the "Tour Topic" field and click "Execute".
Click "Open Tour" which appears on the screen. The search button will be highlighted, and a tooltip displaying "Search Records" will appear.
Click "Next" to proceed to save, or "Back" to return to search. Click "Done" to close the tour.
Click "Execute" again to open the tour, and exit midway using the close button or the Escape key. After exiting, click the search and save buttons on the regular screen.
Change the topic to "Inquiry" and re-run to verify if the tooltip headings change to "Search Inquiries" and "Save Inquiries".
The expected workflow is briefly outlined below.
stateDiagram-v2
[*] --> Ready
Ready --> Search: 案内を開く
Search --> Save: 次へ
Search --> Ready: 閉じる
Save --> Ready: 完了または閉じる
If the input is empty, the subject reverts to Record. Before reflecting it in the heading, it is truncated to 20 characters, and characters interpreted as HTML, such as angle brackets and quotation marks, are removed. Because this is not a button that modifies actual data, please do not enter personal or internal corporate information.
How it works: Pairing elements and descriptions
In Driver.js, the steps of the tour are first arranged in steps. Each step combines the screen element to highlight with the popover used for the description.Official basic examplealso passes steps to driver() and starts the tour with drive().
A shortened implementation of the tutorial looks like this. button() and cleanup are helper functions provided by the Daily Code common runner.
const label = String(v ?? '')
.trim()
.replace(/[&<>"']/g, '')
.slice(0, 20) || '記録';
const search = button('検索', () => say('検索を選びました。'));
const save = button('保存', () => say('保存を選びました。'));
const tour = driver({
showProgress: true,
nextBtnText: '次へ',
prevBtnText: '戻る',
doneBtnText: '完了',
steps: [
{
element: search,
popover: { title: label + 'を検索', description: '対象の記録を探します。' }
},
{
element: save,
popover: { title: label + 'を保存', description: '確認後に変更した記録を保存します。' }
}
]
});
button('案内を開く', () => tour.drive());
cleanup = () => tour.destroy();
You can pass actual DOM elements to steps, not just CSS selectors. This demo creates the target button before passing it to Driver.js. If you start the tour before the screen renders, the target element does not exist yet, and the intended location cannot be highlighted. In enterprise applications where screens are assembled asynchronously, start the guidance after the target is added to the DOM.
The timing of calling drive() also affects the user experience. By making it accessible from help or a Usage Guide rather than automatically starting the tour the moment the page opens, you avoid interrupting users who are already familiar with the operation.
What you learn by changing conditions
When you change the subject from Record to Inquiry, the button descriptions change, but the number of tour steps and target elements do not. In other words, the input string and step configuration are separate settings.
Next, let us stop at Execute and select the search button without clicking Open Guidance. Before the tour starts, there is no overlay covering the screen, and the button can be used normally. Closing it during the tour returns you to the normal screen. The purpose of the tour is not to perform operations on behalf of the user, but to help them understand what to do next.
Closing methods and keyboard operation
In Driver.js 1.3.6 used in this demo, closing operations are enabled by default. The official1.3.6 configurationshows that the default value of allowClose is true, and the action when clicking the overlay is close.The event handling in 1.3.6includes ending with Escape and moving between steps using the left and right arrow keys. Focus movement via the Tab key is also implemented.
However, the mere implementation of keyboard events does not guarantee accessibility, including assistive technologies. Please verify with your actual application and target browsers whether the focus returns to the appropriate position after closing the tour and whether the screen reader reads headings and descriptions as expected. This demo does not include such device verification.
When things do not work
Open Guidance does not appear:Please click "Run" first. The common runner will link the input and demo 35.
Driver.js fails to load:JavaScript and CSS are loaded from a CDN with fixed versions. Please check for network restrictions or developer tool errors.
The tooltip points to the wrong location:Verify that the element passed to the step's element parameter has been created and exists on the screen.
The guide does not close and the screen cannot be operated:Check the settings for the close button, Escape key, and overlay. Setting allowClose to false prevents users from exiting midway, so design the exit mechanism carefully.
The heading does not change even when the topic is changed:Check whether you clicked "Run" after changing the input, and then clicked "Open Guide". Empty fields default to standard values.
Only the diagram fails to render:External fetching of Mermaid may have failed. You can also read the same transitions by opening the diagram source.
Things to decide before using in production
When guiding users through application or edit screens, avoid prompting them to submit simply by explaining it as "Save". Only proceed to the next step after the application confirms that the save process has truly completed. Displaying success-like guidance upon failure can cause users to submit duplicate entries or close the screen without saving.
Additionally, if screen operations are restricted at each step, ensure that important operations of the target application are not hidden behind the guide, that it can be safely closed midway, and that users can go back using both the keyboard and pointer. A design that allows users to resume from an arbitrary help menu is preferable to repeatedly redisplaying the tour. If saving completion status, separately determine user consent, destination, and retention period, keeping the information to a minimum.
Learning Materials and Verification
The inspection verified the daily.js syntax, the HTML configuration ID and initial input values, the target demo function syntax, the Driver.js version, steps, drive(), destroy(), and that the input fields are not hidden by the runner. Tour display, button operations, and keyboard operations in the browser were not verified. Because opening the GitHub Pages URL from this environment returned 'Forbidden. Calls to this URL are not allowed.', page accessibility and the actual screen could not be confirmed.
