Popover

in namespace DotVVM.Framework.Controls.Bootstrap

Renders the Bootstrap Popover widget on inner element.

Usage & Scenarios

Adds a Bootstrap Popover functionality to a control.

https://getbootstrap.com/docs/3.3/javascript/#popovers

Sample 1: Basic Popover

The Popover control has the Title and Content properties that define the title and the contents of the popover dialog respectively.

You can also use Popover on any HTML elements with display: block CSS settings.

<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.

When the AutoPlacement property is set to true, it will dynamically reorient the popover. For example, if the Placement property is set to Left, the popover will display to the left when possible, otherwise it will display on the right.

<bs:Popover Title="Title" Content="Content text" Placement="Left" AutoPlacement="true">
    <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
  • 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 by default a CSS fade transition. 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 milliseconds).

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

The Title and Content properties can also contain HTML. You can allow HTML in these properties using the AllowHtmlInTitleAndContent property.

<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.

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

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 AutoPlacement Boolean Gets or sets value indicating whether additional auto-placement should be used with specified position placement.
attribute
inner element
static value
bindable
default
False
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
null
property icon Content String Gets or sets the contents of the popover.
attribute
inner element
static value
bindable
default
null
property icon Delay Int32 Gets or sets number of milliseconds 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 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 HTML template for creating popover.
attribute
inner element
static value
bindable
default
null
property icon Title String Gets or sets the title of the popover.
attribute
inner element
static value
bindable
default
null
property icon Trigger PopoverTrigger Gets or sets the event which triggers the popover to show.
attribute
inner element
static value
bindable
default
Click

HTML produced by the control