Skip to content

Adding Multiple Steps

You can add multiple steps at once using the addSteps() method. This is useful when you have your tour steps defined in a configuration file, database, or when you want to define them all in a single call.

Method Signature

php
DriverJs::addSteps(array $steps);

or

php
driverjs()->addSteps(array $steps);

Parameters

  • $steps (array): An array of step definitions. Each item should be an associative array with keys like element, title, description, and any other step options.

Example

Using DriverJs::addSteps():

php
use RealRashid\LaravelDriverJs\Facades\DriverJs;

DriverJs::tour('onboarding')
    ->showProgress()
    ->addSteps([
        ['element' => '#header', 'title' => 'Welcome!', 'description' => 'This is the main header.'],
        ['element' => '#nav', 'title' => 'Navigation', 'description' => 'Use these links to navigate.'],
        ['element' => '#sidebar', 'title' => 'Sidebar', 'description' => 'Your tools and shortcuts.', 'side' => 'right'],
        ['element' => '#content', 'title' => 'Content', 'description' => 'Your main content area.'],
        ['element' => '#footer', 'title' => "That's it!", 'description' => "You're all set!"],
    ])
    ->render();

Using driverjs() helper:

php
driverjs('onboarding')
    ->showProgress()
    ->addSteps([
        ['element' => '#header', 'title' => 'Welcome!'],
        ['element' => '#nav', 'title' => 'Navigation'],
        ['element' => '#footer', 'title' => "That's it!"],
    ])
    ->render();

Supported Step Array Keys

Each step array supports the following keys:

KeyTypeDescription
elementstringCSS selector or JS function expression for the target element
titlestringPopover title
descriptionstringPopover description
sidestringPosition: "top", "right", "bottom", "left"
alignstringAlignment: "start", "center", "end"
popover_classstringCustom CSS class for popover
show_buttonsarrayButtons to show: "next", "previous", "close"
disable_buttonsarrayButtons to disable
show_progressboolShow progress text
next_btn_textstringNext button text
prev_btn_textstringPrevious button text
done_btn_textstringDone button text
progress_textstringProgress text template — use and
disable_active_interactionboolDisable interaction with element
on_highlight_startedstringJS callback — called before element is highlighted
on_highlightedstringJS callback — called after element is highlighted
on_deselectedstringJS callback — called when element is deselected
on_next_clickstringJS callback — overrides Next button click for this step
on_prev_clickstringJS callback — overrides Previous button click for this step
on_close_clickstringJS callback — overrides Close button click for this step
on_popover_renderstringJS callback — called after popover DOM is rendered for this step

Replacing Steps

You can replace all existing steps with a new set using setSteps():

php
DriverJs::setSteps([
    ['element' => '#new-header', 'title' => 'New Step'],
    ['element' => '#new-content', 'title' => 'Another Step'],
]);

This clears any previously added steps and adds the new ones.

That's it! You're now equipped to add multiple steps to your tours using Laravel Driver.js.