Tour
Walks the user through the important parts of the page step by step, on first sign-in or for a new feature.
zb:tour zubazar/ui-pro
This component is in Zubazar UI Pro; Zubazar UI Pro brings Zubazar UI with it. Installing Zubazar UI Pro →
Basic usage
Build the tour with a unique name and a steps array whose steps take a target, a title and a text; a data-tour-start button inside starts it.
<zb:tour name="order-tour" :steps="[
['target' => '#order-search', 'title' => 'Order search', 'text' => 'Find orders by number, customer name, or phone number.'],
['target' => '#order-add', 'title' => 'New order', 'text' => 'Record an order that came in by phone here.'],
]">
<div class="flex flex-wrap items-center gap-3">
<div id="order-search" class="w-64"><zb:input name="search" placeholder="Search orders…" /></div>
<zb:button id="order-add">New order</zb:button>
<zb:button variant="white" data-tour-start>Start the tour</zb:button>
</div>
</zb:tour>
| Prop | Values |
|---|---|
name | Unique name (required) |
steps | [['target' => '#selector', 'title' => …, 'text' => …], …] |
data-tour-start | A button inside the component starts the tour |
Placement
placement chooses which side of the target the popover opens on; the default is bottom.
<zb:tour name="placement-tour" :steps="[
['target' => '#placement-order', 'title' => 'On the right', 'text' => 'right: the popover opens to the right of the order card.', 'placement' => 'right'],
['target' => '#placement-courier', 'title' => 'On the left', 'text' => 'left: the popover opens to the left of the courier card.', 'placement' => 'left'],
['target' => '#placement-note', 'title' => 'On top', 'text' => 'top: the popover opens above the delivery note.', 'placement' => 'top'],
['target' => '#placement-start', 'title' => 'No room', 'text' => 'This step wanted to open on top; since there was no room there, it moved below.', 'placement' => 'top'],
]">
<zb:button id="placement-start" variant="white" data-tour-start>Show placements</zb:button>
</zb:tour>
<div class="mt-6 flex items-start justify-between gap-6">
<div id="placement-order" class="w-40 rounded-sm bg-surface p-4 text-sm shadow-sm">
<p class="text-xs text-muted">Order</p>
<p class="font-semibold text-ink">#10482</p>
</div>
<div id="placement-courier" class="w-40 rounded-sm bg-surface p-4 text-sm shadow-sm">
<p class="text-xs text-muted">Courier</p>
<p class="font-semibold text-ink">Mehmet Kaya</p>
</div>
</div>
<p id="placement-note" class="mt-32 rounded-sm bg-surface p-4 text-sm shadow-sm">Delivery note: the building entrance is on the back street; the package can be left with the doorman.</p>
| Prop | Values |
|---|---|
steps.*.placement | top | bottom | left | right |
placement | Default direction of the steps; default bottom |
Starting from anywhere
Start the tour from anywhere on the page by dispatching a start-tour event with its name.
<div class="flex flex-wrap items-center justify-between gap-3">
<h3 class="text-base font-semibold text-ink">Monthly report</h3>
<zb:button variant="ghost" size="sm" x-data x-on:click="$dispatch('start-tour', { name: 'report-tour' })">How do I use this page?</zb:button>
</div>
<div class="mt-4 flex flex-wrap items-center gap-3">
<div id="report-period" class="w-48"><zb:select name="period" :options="['2026-09' => 'September 2026', '2026-08' => 'August 2026']" /></div>
<zb:button id="report-export" variant="white">Export to Excel</zb:button>
</div>
<zb:tour name="report-tour" :steps="[
['title' => 'Monthly report', 'text' => 'This page summarizes the sales figures for the month you select. Here is a quick look.'],
['target' => '#report-period', 'title' => 'Period', 'text' => 'Choose which month the report covers here.'],
['target' => '#report-chart', 'title' => 'Weekly chart', 'text' => 'How the sales are spread across the weeks.'],
['target' => '#report-export', 'title' => 'Export', 'text' => 'Download the rows of the selected period as an Excel file.'],
]" />
| Prop | Values |
|---|---|
start-tour | $dispatch('start-tour', { name: '…' }) |
steps.*.target | Empty: opens in the middle · not found: the step is skipped |
Autostart and remembering
autostart starts the tour when the page loads; with remember, a finished or skipped tour doesn't open on its own again in this browser.
<zb:tour name="first-login" autostart remember :steps="[
['title' => 'Welcome', 'text' => 'A few steps to introduce the main parts of the panel.'],
['target' => '#main-menu', 'title' => 'Menu', 'text' => 'Reach orders, customers, and reports from here.', 'placement' => 'right'],
['target' => '#notifications', 'title' => 'Notifications', 'text' => 'Support tickets assigned to you are listed here.'],
]" />
{{-- Can be started manually even if it has been remembered. --}}
<zb:button variant="ghost" x-data x-on:click="$dispatch('start-tour', { name: 'first-login' })">Replay the introduction</zb:button>
| Prop | Values |
|---|---|
autostart | true | false |
remember | true | false · key: 'zb-tour:' + name |
Props
The values the component takes. What are props and slots?
| Prop | Type | Default | Description |
|---|---|---|---|
name | — | — | Required. The name used in the start-tour event; the remember key is also derived from it |
steps | — | [] | Array of steps; each step takes target, title, text, and an optional placement |
placement | — | bottom | For steps without a direction of their own: top · bottom · left · right |
autostart | boolean | false | Starts when the page loads |
remember | boolean | false | A finished or skipped tour does not start on its own again in this browser (localStorage: 'zb-tour:' + name) |
steps.*.target | — | null | CSS selector of the target. If empty, the popover opens in the middle of the screen; if the element is not found or is hidden, the step is skipped |
steps.*.title | — | '' | Popover title; also the accessible name of the dialog |
steps.*.text | — | '' | Description; written as plain text (HTML is not rendered) |
steps.*.placement | — | bottom | top · bottom · left · right; if there is no room, it moves to another side and stays on screen |
Slots: default: the tour's content, e.g. a button with data-tour-start (optional). Events: start-tour { name } starts the tour; when the tour closes, tour-ended { name, finished } is dispatched.
Advanced
With Livewire
Dispatch start-tour from the server, and when the tour closes, record on the user that it was seen through the tour-ended event. If you tie autostart to that record, the tour doesn't open again in another browser either.
// <zb:tour
// name="first-login"
// :steps="$tourSteps"
// :autostart="! auth()->user()->tour_seen"
// x-on:tour-ended.window="$event.detail.name === 'first-login' && $wire.markTourSeen()"
// />
public function markTourSeen(): void
{
auth()->user()->forceFill(['tour_seen' => true])->save();
}
public function showHelp(): void
{
$this->dispatch('start-tour', name: 'first-login');
}
| Prop | Values |
|---|---|
tour-ended | { name, finished } · finished: false = skipped |
Keyboard and accessibility
The tour works with the keyboard alone: Tab and Shift+Tab cycle through the popover's buttons, and → and ← change the step. Esc ends the tour, and it counts as skipped.
<zb:tour name="form-tour" :steps="[
['target' => '#customer-name', 'title' => 'Full name', 'text' => 'Enter the customer name as it should appear on invoices.'],
['target' => '#customer-phone', 'title' => 'Phone', 'text' => 'Enter a mobile number the courier can reach.'],
['target' => '#customer-save', 'title' => 'Save', 'text' => 'Saved customers appear in the customer list.', 'placement' => 'right'],
]">
<zb:button variant="white" data-tour-start>Tour the form</zb:button>
</zb:tour>
<div class="mt-6 max-w-sm space-y-4">
<div id="customer-name"><zb:input name="name" label="Full name" /></div>
<div id="customer-phone"><zb:input name="phone" type="tel" label="Phone" /></div>
<zb:button id="customer-save">Save</zb:button>
</div>
| Prop | Values |
|---|---|
Tab / Shift+Tab | Between the popover's buttons |
→ / ← | Next / previous step |
Esc | Ends the tour |
Developer notes
- At each step the target is highlighted, the rest of the screen dims, and a popover opens next to it with a title, a description, a step counter and Back / Next step buttons. On the last step, "Finish" appears instead of "Next step".
data-tour-startneeds no Alpine; on pages with Alpine the 2.x way,start(), works too.- If there is no room on the chosen side, the popover moves to the opposite side, then to the other two, and stays on screen; the last step of the Placement example shows this.
- A step without a
targetopens in the middle of the screen, which suits opening the tour with a welcome. - A step whose target is not on the page or is hidden is skipped and not counted: that is why the chart step doesn't appear in the Starting from anywhere example, and the counter shows 3 steps.
autostartruns once the page has loaded, images included; the example would take focus at once, so it is not shown live.rememberis stored in localStorage underzb-tour:followed by the tour's name (e.g.zb-tour:first-login); to turn autostart back on, delete it withlocalStorage.removeItem('zb-tour:first-login').data-tour-startandstart-tourignore what was remembered, so the tour can always be replayed by hand.- If the browser does not allow storage (e.g. in some private windows), the tour simply does not remember; it does not throw an error.
- Extra attributes you pass to the component, such as
x-on:, are added to the root element. - The button texts (Back, Next step, Finish, Skip tour) and the counter format (
:current / :total) are translated with__().
Events
| Event | detail | Description |
|---|---|---|
tour-ended | { name, finished } | Sent from the component when the tour finishes or is skipped (Skip button, Escape); it bubbles to window. finished is false when skipped. |
start-tour (listens) | { name } | Dispatched on window, it starts the tour with that name. |
Accessibility
- Focus
- At each step focus moves to the popover; when the tour closes, it returns to the element that started it. While the tour is open, the page behind it cannot be clicked.
- Screen readers
- The popover has
role="dialog"andaria-modal="true"; it takes its name from the title and its description from the text and the counter, and screen readers read all three. - Motion
- If the operating system asks for reduced motion, the page scrolls to the target without animation.