ProductTour
ProductTour
displays a sequence of checkpoints with anchors around the DOM.
A ProductTour
takes a list of tour objects and will only support one enabled tour at a time. If multiple
tours are enabled, ProductTour
will only render the first enabled in the tours
list.
Checkpoints
are rendered in the order they're listed in the checkpoint array.
The checkpoint objects themselves have additional props that can override the props defined in ProductTour
.
Basic Usage
Show editable code example
Any Paragon component or export may be added to the code example.
() => {const [isTourEnabled, setIsTourEnabled] = useState(false);const myFirstTour = {tourId: 'myFirstTour',advanceButtonText: 'Next',dismissButtonText: 'Dismiss',endButtonText: 'Okay',enabled: isTourEnabled,onDismiss: () => setIsTourEnabled(false),onEnd: () => setIsTourEnabled(false),checkpoints: [{advanceButtonText: 'Onward', // Override the default advanceButtonText abovebody: "Here's the first checkpoint!",placement: 'top',target: '#checkpoint-1',title: 'First checkpoint',},{body: "Here's the second checkpoint!",onDismiss: () => {console.log('Dismissed the second checkpoint');setIsTourEnabled(false);}, // Override the default onDismiss aboveplacement: 'right',target: '#checkpoint-2',title: 'Second checkpoint',},{body: "Here's the third checkpoint!",placement: 'bottom',target: '#checkpoint-3',title: 'Third checkpoint',onEnd: () => {console.log('Ended the third checkpoint');setIsTourEnabled(false);} // Additional logic for the onEnd callback to be called on the last checkpoint}],};return (<><ProductTourtours={[myFirstTour]}/><Button onClick={() => setIsTourEnabled(true)}>Open a product tour</Button><Row className="w-100 m-0 mt-3 p-2 justify-content-around"><div id="checkpoint-1"><Icon src={Check}/></div><div id="checkpoint-2"><Icon src={Check}/></div><div id="checkpoint-3"><Icon src={Check}/></div></Row></>);}
Theme Variables (SCSS)#
$checkpoint-background-color: $light-300 !default;$checkpoint-body-color: $gray-700;$checkpoint-border-color: $brand !default;$checkpoint-border-width: 8px !default;$checkpoint-breadcrumb-color: $primary !default;$checkpoint-arrow-width: 15px !default;$checkpoint-max-width: 480px !default;$checkpoint-z-index: 1060 !default;
Props API#
ProductTour Props API
- toursDefault{ advanceButtonText: '', checkpoints: { advanceButtonText: '', body: '', dismissButtonText: '', endButtonText: '', onAdvance: () => {}, onDismiss: () => {}, placement: 'top', title: '', showDismissButton: undefined, }, dismissButtonText: '', endButtonText: '', onDismiss: () => {}, onEnd: () => {}, onEscape: () => {}, startingIndex: 0, }
shape
{advanceButtonText:node
,checkpoints:shape
{advanceButtonText:node
,body:node
,dismissButtonText:node
,endButtonText:node
,onAdvance:func
,onDismiss:func
,onEnd:func
,placement:enum
'top' | 'top-start' | 'top-end' | 'right-start' | 'right' | 'right-end' | 'left-start' | 'left' | 'left-end' | 'bottom' | 'bottom-start' | 'bottom-end',target:string
Required,title:node
,showDismissButton:}bool
,[]
,dismissButtonText:node
,enabled:bool
Required,endButtonText:node
,onDismiss:func
,onEnd:func
,onEscape:func
,startingIndex:number
,tourId:}string
Required,[]
Usage Insights#
ProductTour
Project Name | Paragon Version | Instance Count | |
---|---|---|---|
frontend-app-admin-portal | 20.26.3 | 1 | |
frontend-app-discussions | 20.15.0 | 1 | |
frontend-app-learning | 20.28.4 | 1 |