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
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
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
Content String Gets or sets the contents of the popover.
attribute
inner element
static value
bindable
default
Delay Double Gets or sets number of seconds to delay the showing and hiding the popover.
attribute
inner element
static value
bindable
default
0
EnableAnimation Boolean Gets or sets value indicating whether the popover should use the fade animation.
attribute
inner element
static value
bindable
default
True
Enabled Boolean Gets or sets whether the popover is active or not.
attribute
inner element
static value
bindable
default
True
IsDisplayed Boolean Gets or sets whether the popover is actually displayed.
attribute
inner element
static value
bindable
default
False
Placement PopoverPlacement Gets or sets the side on which the popover is placed.
attribute
inner element
static value
bindable
default
Right
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
Title String Gets or sets the title of the popover.
attribute
inner element
static value
bindable
default
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.1/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="Default" />
</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="500">
    <bs:Button Text="Text" Type="Info" />
</bs:Popover>

<bs:Popover Title="Title" Content="Content text" Container="body">
    <bs:Button Text="Text" Type="Default" />
</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" 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="Default" />
</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.

Send message