Bootstrap4 Popover
A popover control is similar to a tooltip; it is displayed after the mouse clicks on the element. Unlike a tooltip, it can display more content.
How to Create a Popover
Create a popover by adding data-toggle="popover" to the element.
The content of the title attribute is the popover title, and the data-content attribute shows the popover's text content:
<a href="" data-toggle="popover" title=">Popover Title
"
data-content
=
"
Popover Content
"
Click Me Multiple Times
a
Note: The popover should be written in the jQuery initialization code: then call the popover() method on the specified element.
The following example can use popovers anywhere in the document:
Example
$
(
document
)
.
ready
(
function
(
)
{
$
(
'
[data-toggle="popover"]
'
)
.
popover
(
)
;
}
)
;
Try it »
Specifying the Popover Position
By default, the popover is displayed on the right side of the element.
You can use the data-placement attribute to set the direction in which the popover is displayed: top, bottom, left or right:
Example
<a href="" title="Header" data-toggle="popover" data-placement="top" data-content="Content">Click me
a
<a href="" title="Header" data-toggle="popover" data-placement="bottom" data-content="Content">Click me
a
<a href="" title="Header" data-toggle="popover" data-placement="left" data-content="Content">Click me
a
<a href="" title="Header" data-toggle="popover" data-placement="right" data-content="Content">Click me
a
Try it »
Used in a button:
Example
<button type="button" class=">btn btn-secondary
"
data-container
=
"
body
"
data-toggle
=
"
popover
"
data-placement
=
"
top
"
data-content
=
"
Vivamus sagittis lacus vel augue laoreet rutrum faucibus.
"
Popover on top
button
<button type="button" class=">btn btn-secondary
"
data-container
=
"
body
"
data-toggle
=
"
popover
"
data-placement
=
"
right
"
data-content
=
"
Vivamus sagittis lacus vel augue laoreet rutrum faucibus.
"
Popover on right
button
<button type="button" class=">btn btn-secondary
"
data-container
=
"
body
"
data-toggle
=
"
popover
"
data-placement
=
"
bottom
"
data-content
=
"
Vivamus sagittis lacus vel augue laoreet rutrum faucibus.
"
Popover on bottom
button
<button type="button" class=">btn btn-secondary
"
data-container
=
"
body
"
data-toggle
=
"
popover
"
data-placement
=
"
left
"
data-content
=
"
Vivamus sagittis lacus vel augue laoreet rutrum faucibus.
"
Popover on left
button
Try it »
Closing Popovers
By default, a popover closes after clicking the specified element again. You can use the data-trigger="focus" attribute to close the popover when clicking outside the element:
Example
<a href="" title=">Dismiss Popover
"
data-toggle
=
"
popover
"
data-trigger
=
"
focus
"
data-content
=
"
Click elsewhere in the document to close me
"
Click me
a
Try it »
**Tip:** If you want to show on mouse move over the element and hide when removed, you can use the data-trigger attribute and set its value to "hover":
Example
<a href="" title="Header" data-toggle="popover" data-trigger="hover" data-content=">Some Content
"
Hover over me
a
Try it »