Onboard
Guide users through the initial steps of using your product
Use the onboard
function to guide your users through the initial steps of using your product, service, or application in an interactive way. Using the function can improve user experience, increase your engagement and steamline guidance. To test the onboard
function, click on the button below.
You can:
- Use as many characters in your tooltips as needed
- Change the position of your tooltip
- Use HTML tags inside your tooltips
- Attach event listeners
The border-radius
of your highlight will adapt to your element.
The onboarding can be created with any UI element. In this example, we use the Sheet
component to handle the onboarding steps.
- The first step is to create the UI elements that you want to use to handle onboarding. Depending on your project, this part might differ. In our case, we use a
Sheet
component. - The first step of actually using the
onboard
function is creating the steps. The steps are represented by an array of objects. Each step is attached to an HTML element using query selectors. Each object can have the following properties:
- Instantiate the
onboard
function and pass thesteps
array as the first argument. Theonboard
function also accepts a second parameter which is the configuration object. In our case, we define three callback function:onEnd
: Executed when the onboarding ends. In this example, we close the modal and reset the previous/next button states.onPrev
: Executed whenonboard.next
is called.onNext
: Executed whenonboard.prev
is called.
That configuration object can also have the following other properties:
- The onboarding is ended with
onboarding.end
when the modal is closed. - When the user clicks on the
.start
button, we can start the onboarding using theonboarding.start
method. - When the previous button is clicked, we can call
onboarding.prev
to regress back to the previous step defined in thesteps
array. Note that we can useonboarding.getStep
to get the current step index and use that to execute additional code, such as disabling the previous button or updating the “Next” button text. - When the next button is clicked, we can call
onboarding.next
to progress to the next step. Usingonboarding.getStep
we can find out if the user is at the last step. In this case, we can close the modal and reset the buttons. Note that we don’t need to callonboarding.end
to end the onboarding. This is automatically handled when the first or last step is reached.
Accessibility
-
The
onboard
function comes with many built-in accessibility features. Onboarding is automatically ended when the user clicks on the overlay or hits theEsc
button. These functions can be disabled if necessary using theendOnOverlayClick
andendOnEsc
props on the configuration object. -
The active step is also automatically scrolled into viewport if its not visible when the step is reached. The tooltip and highlight is also repositioned if the size of the viewport changes, making it work responsively across all devices.
-
You can change the padding of the highlight and adjust the position of the tooltip using the
boxPadding
andtextPadding
props.
API
Steps | Default | Purpose |
---|---|---|
data | [] | Sets the steps for the onboarding process. |
data.element | - | Sets the element for the step. |
data.tooltip | - | Sets the tooltip for the step. |
data.tooltipPosition | - | Sets the tooltip position for the step. |
OnboardConfig | Default | Purpose |
---|---|---|
boxPadding | 0 | Sets the padding of the highlight for the step. |
textPadding | 5 | Sets the padding of the tooltip from the box. |
endOnOverlayClick | true | Sets whether the onboarding should be terminated when the overlay is clicked. |
endOnEsc | true | Sets whether the onboarding should be terminated when the esc key is pressed. |
onStart | - | Adds a callback function that is executed when the onboarding starts. |
onEnd | - | Adds a callback function that is executed when the onboarding ends. |
onPrev | - | Adds a callback function that is executed when the prev function is called. |
onNext | - | Adds a callback function that is executed when the next function is called. |
onboard function | Purpose |
---|---|
start | Stars the onboarding. |
end | Stops the onboarding. |
next | Proceeds to the next onboarding step. |
prev | Regress to the previous onboarding step. |
getStep | Returns the index of the current step. |