Popover

in namespace DotVVM.Bootstrap5.Controls

Allows to add the Bootstrap Popover widget on the inner element.

Usage & Scenarios

Adds a Bootstrap Popover functionality to a control.

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

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" Body="Content text">
    <a>Simplest link with Popover</a>
</bs:Popover>

<bs:Popover Title="Title text" Body="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" Body="Content text" Placement="Auto">
    <bs:Button Text="Text" Type="Success" />
</bs:Popover>

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

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

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

<bs:Popover Title="Title" Body="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" Body="Content text" Trigger="Click">
    <bs:Button Text="Click" Type="Danger" />
</bs:Popover>

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

<bs:Popover Title="Title" Body="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" Body="Content text" EnableAnimation="false">
    <bs:Button Text="Text" Type="Danger" />
</bs:Popover>

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

<bs:Popover Title="Title" Body="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}" 
            Body="{value: ContentHtml}" 
            AllowHtmlInTitleAndContent="true">
    <bs:Button Text="Text" Type="Success" />
</bs:Popover>
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>";
}

Properties

Name Type Description Notes Default Value
property icon AllowHtmlInTitleAndContent Boolean Gets or sets whether the title and body can contain HTML.
attribute
inner element
static value
bindable
default
False
property icon Body String Gets or sets the popover body.
attribute
inner element
static value
bindable
default
null
property icon Container String Gets or sets the selector for athen 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 DotvvmControl Gets or sets the element for which the popover is displayed.
attribute
inner element
static value
bindable
default
null
property icon Delay Int32? Gets or sets number of miliseconds to delay the showing and hiding the popover.
attribute
inner element
static value
bindable
default
null
property icon DisableHtmlSanitization Boolean Gets or sets whether the inner HTML should be sanitized.
attribute
inner element
static value
bindable
default
False
property icon EnableAnimation Boolean Gets or sets whether the popover should use the fade animation.
attribute
inner element
static value
bindable
default
True
property icon Enabled IValueBinding<Boolean> Gets or sets whether the popover is active or not.
attribute
inner element
static value
bindable
default
null
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 Title String Gets or sets the popover title.
attribute
inner element
static value
bindable
default
null
property icon Trigger Trigger[] Gets or sets the event which triggers the popover to show.
attribute
inner element
static value
bindable
default
null
property icon Visible Boolean Gets or sets whether the control is visible. When set to false, `style="display: none"` will be added to this control.
attribute
inner element
static value
bindable
default
True

HTML produced by the control