Version:
2.0

Popover

in namespace DotVVM.Framework.Controls.Bootstrap4

Applies the Bootstrap Popover widget on the inner element.

Properties

Name Type Description Notes Default Value
property icon AllowHtmlInTitleAndContent Boolean Gets or sets value indicating whether to insert HTML into popover. When false jQuery's text method will be used to insert content into the DOM.
attribute
inner element
static value
bindable
default
False
property icon AllowHtmlSanitization Boolean Gets or sets whether the inner HTML is sanitized. https://getbootstrap.com/docs/4.3/getting-started/javascript/#sanitizer
attribute
inner element
static value
bindable
default
True
property icon Container String Gets or sets the selector for an element in which the popover is created. It allows to position the popover in the flow of the document near the triggering element which will prevent the popover from floating away from the triggering element during a window resize.
attribute
inner element
static value
bindable
default
body
property icon Content String Gets or sets the contents of the popover.
attribute
inner element
static value
bindable
default
property icon Delay Double Gets or sets number of seconds to delay the showing and hiding the popover.
attribute
inner element
static value
bindable
default
0
property icon EnableAnimation Boolean Gets or sets value indicating whether the popover should use the fade animation.
attribute
inner element
static value
bindable
default
True
property icon Enabled Boolean Gets or sets whether the popover is active or not.
attribute
inner element
static value
bindable
default
True
property icon IsDisplayed Boolean Gets or sets whether the popover is actually displayed.
attribute
inner element
static value
bindable
default
False
property icon Placement PopoverPlacement Gets or sets the side on which the popover is placed.
attribute
inner element
static value
bindable
default
Right
property icon PopoverTemplate ITemplate Gets or sets the HTML template for creating popover. The outermost wrapper element should have the .popover class. The popover's title will be injected into the element with class popover-header. The popover's content will be injected into the element with class popover-body. The element with class arrow will become the popover's arrow.
attribute
inner element
static value
bindable
default
property icon Title String Gets or sets the title of the popover.
attribute
inner element
static value
bindable
default
property icon Trigger PopoverTrigger Gets or sets the event which triggers the popover to show.
attribute
inner element
static value
bindable
default
Click

Events

Name Type Description

Usage & Scenarios

Adds a Bootstrap Popover functionality to a control.

https://getbootstrap.com/docs/4.3/components/popovers/

HTML Rendered by the Control

Sample 1: Basic Popover

The Popover control has the Title and Content properties that define the title and the body of the popover.

You can use the Popover control to wrap links, buttons, or any HTML block elements.

<bs:Popover Title="Title text" Content="Content text">
    <a>Simplest link with Popover</a>
</bs:Popover>

<bs:Popover Title="Title text" Content="Content text">
    <div style="width: 220px">
        simple div
    </div>
</bs:Popover>

Sample 2: Popover Placement

The Popover control has also the Placement property. Use this property to specify on which side the overlay appears.

The Placement property can be set to Top, Bottom, Left, Right and Auto.

<bs:Popover Title="Title" Content="Content text" Placement="Auto">
    <bs:Button Text="Text" Type="Success" />
</bs:Popover>

<bs:Popover Title="Title" Content="Content text" Placement="Bottom">
    <bs:Button Text="Bottom" Type="Info" />
</bs:Popover>

<bs:Popover Title="Title" Content="Content text" Placement="Left">
    <bs:Button Text="Left" Type="Success" />
</bs:Popover>

<bs:Popover Title="Title" Content="Content text" Placement="Right">
    <bs:Button Text="Right" Type="Danger" />
</bs:Popover>

<bs:Popover Title="Title" Content="Content text" Placement="Top">
    <bs:Button Text="Top" Type="Warning" />
</bs:Popover>

Sample 3: Popover Triggers

The Popover control has the Trigger property which specifies on which event the overlay should appear.

The values are Click, Focus and Hover.

<bs:Popover Title="Title" Content="Content text" Trigger="Click">
    <bs:Button Text="Click" Type="Danger" />
</bs:Popover>

<bs:Popover Title="Title" Content="Content text" Trigger="Focus">
    <bs:Button Text="Focus" Type="Primary" />
</bs:Popover>

<bs:Popover Title="Title" Content="Content text" Trigger="Hover">
    <bs:Button Text="Hover" Type="Warning" />
</bs:Popover>

Sample 4: Popover Animation, Delay and Container

The Popover control uses CSS fade transition by default. It is possible to disable it using the EnableAnimation property.

The Delay property is used to delay showing and hiding of the popover (value represents number of seconds).

The Container property specifies the selector for an element in which the popover is created. It allows to position the popover in the flow of the document near the triggering element which will prevent the popover from floating away from the triggering element during a window resize.

<bs:Popover Title="Title" Content="Content text" EnableAnimation="false">
    <bs:Button Text="Text" Type="Danger" />
</bs:Popover>

<bs:Popover Title="Title" Content="Content text" Delay="1">
    <bs:Button Text="Text" Type="Info" />
</bs:Popover>

<bs:Popover Title="Title" Content="Content text" Container="body">
    <bs:Button Text="Text" Type="Secondary" />
</bs:Popover>

Sample 5: Allowing HTML in Title and Content

If you want to allow HTML in Title and Content properties, you must turn it on explicitly using the AllowHtmlInTitleAndContent property.

If you allow HTML in popovers, make sure the HTML is safe to display. See Cross-site scripting for more information.

<bs:Popover Title="{value: TitleHtml}" 
            Content="{value: ContentHtml}" 
            AllowHtmlInTitleAndContent="true">
    <bs:Button Text="Text" Type="Success" />
</bs:Popover>
using DotVVM.Framework.ViewModel;

namespace DotvvmWeb.Views.Docs.Controls.bootstrap.Popover.sample5
{
    public class ViewModel : DotvvmViewModelBase
    {
        public string TitleHtml { get; set; } = "<h3>Title with html</h3>";
        public string ContentHtml { get; set; } = "This <i>content</i> uses <b>html</b> <u>tags</u>";
    }
}

Sample 6: Popover Template

The Popover control can define custom look using the PopoverTemplate property.

The popover's title must be decorated with popover-header CSS class.

The popover's content must be decorated with popover-body CSS class.

Element marked with arrow CSS class will become the popover's arrow.

The outermost wrapper element should have the popover CSS class.

<bs:Popover Title="Title" Content="Content text">
    <PopoverTemplate>
        <div class="popover" role="tooltip">
            <div class="arrow"></div>
            <div class="popover-header"></div>
            <div class="popover-body"></div>
            <img src="https://www.dotvvm.com/Content/img/product-detail-bs/bs-to-dotvvm.svg" />
        </div>
    </PopoverTemplate>
    <bs:Button Text="Text" Type="Primary" />
</bs:Popover>

Sample 7: HTML sanitization

All HTML passed into Popover by default goes through Bootstrap HTML sanitizer. It filters out all non-whitelisted tags and attributes.

List of allowed tags and attributes

To disable HTML sanitization, set AllowHtmlSanitization to false.

Make sure the template is safe and cannot enable anyone to make a XSS attack.

<bs:Popover Title="Title" Content="Content text" AllowHtmlSanitization="false" >
    <PopoverTemplate>
        <div class="popover" role="tooltip">
            <div class="arrow"></div>
            <div class="popover-header" style="color: orchid; font-weight: bold; font-size: larger;"></div>
            <div class="popover-body" style="color: forestgreen;"></div>
        </div>
    </PopoverTemplate>
    <bs:Button Text="Text" Type="Primary" />
</bs:Popover>

Suggestions

Help & Contribute

The documentation is maintained on GitHub.
We'll be happy if you edit the page and create a pull request.

Edit on Github

Send message