Popovers
Add small overlays of content for super concise functions or toggle-able options.
Examples:
As raw HTML:
<a
href="#"
class="btn"
data-toggle="popover"
data-content="This is the popover content. It can (optionally) contain <strong><u>HTML</u></strong>"
data-title="Popover Title"
data-html="true">Click to toggle popover</a>
Or as helper parameters:
{{
html.link({
'href': '#',
'label': 'Click to toggle popover',
'data-toggle': 'popover',
'data-title': 'Popover Title',
'data-content': 'This is the popover content. It can (optionally) contain <strong><u>HTML</u></strong>',
'data-html': true
})
}}
See the Pen docs - form - popover by Pulsar (@pulsar) on CodePen.
Popovers on disabled elements require wrapper elements
To add a popover to a disabled or .disabled
element, put the element inside of a <div>
and apply the popover to that <div>
instead.
Options
Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-
, as in data-animation=""
.
Name | type | default | description |
---|---|---|---|
animation | boolean | true | apply a CSS fade transition to the tooltip |
html | boolean | false | Insert HTML into the popover. If false, jQuery's text method will be used to insert content into the DOM. Use text if you're worried about XSS attacks. |
placement | string | function | 'right' | how to position the popover - top | bottom | left | right | auto. When "auto" is specified, it will dynamically reorient the popover. For example, if placement is "auto left", the tooltip will display to the left when possible, otherwise it will display right. |
selector | string | false | if a selector is provided, tooltip objects will be delegated to the specified targets if a selector is provided, tooltip objects will be delegated to the specified targets. in practice, this is used to enable dynamic HTML content to have popovers added. See this and an informative example. |
trigger | string | 'click' | how popover is triggered - click | hover | focus | manual |
title | string | function | '' | default title value if title attribute isn't present |
content | string | function | '' | default content value if data-content attribute isn't present |
delay | number | object | 0 |
delay showing and hiding the popover (ms) - does not apply to manual trigger type If a number is supplied, delay is applied to both hide/show Object structure is: |
container | string | false | false |
Appends the popover to a specific element. Example: |
Clickovers
Clickover is a variation of popovers where the popover will be closed when the user clicks anywhere else on the page (popovers require the same toggle to be clicked). To use a popover instead of a clickover, use the rel="clickover"
attribute instead of data-toggle="popover"
.
{{
html.link({
'href': '#',
'label': 'Click to toggle clickover',
'rel': 'clickover',
'data-content': 'I am a clickover'
})
}}