Tooltip positions
By default, Intro.js places each tooltip below the highlighted element and moves it automatically when there isn’t enough room. You can choose a position for each step, set a default for the whole tour, or turn automatic positioning off.
Available positions
| Position | Where the tooltip appears |
|---|---|
bottom | Below the element, aligned to its left edge. This is the default. |
top | Above the element, aligned to its left edge. |
left | To the left of the element. |
right | To the right of the element. |
bottom-left-aligned | Below the element, aligned to its left edge (same as bottom). |
bottom-middle-aligned | Below the element, centered. |
bottom-right-aligned | Below the element, aligned to its right edge. |
top-left-aligned | Above the element, aligned to its left edge (same as top). |
top-middle-aligned | Above the element, centered. |
top-right-aligned | Above the element, aligned to its right edge. |
floating | In the middle of the screen, not attached to any element. |
Set the position of a step
Use the position property to choose where a step’s tooltip appears:
introJs.tour().setOptions({
steps: [
{
element: document.querySelector('.card-demo'),
intro: 'Tooltip has position right',
position: 'right'
},
{
element: document.querySelector('.card-demo-link'),
intro: 'Tooltip has position left',
position: 'left'
},
{
element: document.querySelector('.card-demo-text'),
intro: 'Tooltip has position bottom',
position: 'bottom'
},
{
element: document.querySelector('.card-demo'),
intro: 'Tooltip has position top',
position: 'top'
}]
}).start();If you define your tour with HTML attributes, use data-position instead:
<button data-intro="Create a new project" data-position="right">
New project
</button>See all attributes on the Tour HTML Attributes page.
Align the tooltip above or below an element
Tooltips above or below an element can be aligned to its left edge, center or right edge. This is useful for elements near the edge of the screen, or for wide elements where a centered tooltip looks better:
introJs.tour().setOptions({
steps: [
{
element: document.querySelector('.card-demo'),
intro: 'Centered below the card',
position: 'bottom-middle-aligned'
},
{
element: document.querySelector('.card-demo'),
intro: 'Aligned to the right edge, below the card',
position: 'bottom-right-aligned'
},
{
element: document.querySelector('.card-demo'),
intro: 'Centered above the card',
position: 'top-middle-aligned'
}]
}).start();Since Intro.js v8.4.0, the alignment you choose is kept as long as the tooltip fits. In older versions, Intro.js picks the alignment automatically unless you set autoPosition: false.
Set a default position for all steps
Use the tooltipPosition option to change the default for every step. A step’s own position still takes priority:
introJs.tour().setOptions({
tooltipPosition: 'right',
steps: [
{ element: '#search', intro: 'Uses the default: right' },
{ element: '#settings', intro: 'Overrides it', position: 'top' },
],
}).start();How automatic positioning works
The autoPosition option is on by default. Before it shows a tooltip, Intro.js checks whether it fits next to the element:
- If the tooltip fits in the position you asked for, Intro.js uses it.
- If it doesn’t fit, Intro.js tries the positions in
positionPrecedencein order, and uses the first one that fits. The default order isbottom,top,right,left. - If the tooltip doesn’t fit anywhere, for example because the element fills most of the screen, it’s shown floating in the middle of the screen.
For top and bottom tooltips, Intro.js also picks an alignment that keeps the tooltip on screen, unless you asked for a specific one.
To prefer the sides of elements over the space above and below them, change the order:
introJs.tour().setOptions({
positionPrecedence: ['right', 'left', 'bottom', 'top'],
steps: [/* ... */],
}).start();Turn off automatic positioning
Set autoPosition to false to always use the exact position you defined, even when the tooltip doesn’t fully fit on screen:
introJs.tour().setOptions({
autoPosition: false,
steps: [
{
element: document.querySelector('.card-demo'),
intro: 'Always on the left, even without enough room',
position: 'left'
}]
}).start();Only turn this off if you’ve tested the tour on small screens, because tooltips may be cut off.
Show a tooltip in the middle of the screen
Use the floating position, or leave out element, to show a step in the middle of the screen. This works well for welcome and closing messages. See the floating tooltip example.
Troubleshooting
The tooltip ignores the position I set.
It probably doesn’t fit there, so automatic positioning moved it. Try a different position, make the tooltip content shorter, or set autoPosition: false.
The tooltip appears in the middle of the screen.
There isn’t enough room on any side of the element. This often happens with large elements on small screens. Highlight a smaller element, or use a floating step on purpose.
The tooltip covers something important.
Choose a position on the other side of the element, or change positionPrecedence so Intro.js tries a better side first.
I need different positions for hints.
Hints have their own position setting. See the hintPosition option.