Version: 2.0 |

Tooltip

in namespace DotVVM.Framework.Controls.Bootstrap4

Applies the Bootstrap Tooltip widget on the inner element.

Properties

Name Type Description Notes Default Value
AllowHtml Boolean Gets or sets the whether tooltip allows HTML content in title.
attribute
inner element
static value
bindable
default
False
AllowHtmlSanitization Boolean Gets or sets whether the inner HTML (Tooltip Template) is sanitized. https://getbootstrap.com/docs/4.3/getting-started/javascript/#sanitizer
attribute
inner element
static value
bindable
default
True
Delay Double Gets or sets the delay (in seconds) before the tooltip is shown or closed.
attribute
inner element
static value
bindable
default
0
EnableAnimation Boolean Gets or sets whether the tooltip should use fade animation.
attribute
inner element
static value
bindable
default
True
Enabled Boolean Gets or sets whether the tooltip is active.
attribute
inner element
static value
bindable
default
True
IsDisplayed Boolean Gets or sets whether the tooltip is actually displayed.
attribute
inner element
static value
bindable
default
False
Placement TooltipPlacement Gets or sets the placement of the tooltip.
attribute
inner element
static value
bindable
default
Left
Title String Gets or sets the text of the tooltip.
attribute
inner element
static value
bindable
default

Events

Name Type Description

Usage & Scenarios

Adds the Bootstrap Tooltip to an element or control.

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

HTML Rendered by the Control

Sample 1: Basic Tooltip

The control has the Title property which specifies the text displayed in the tooltip.

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

<bs:Tooltip Title="This element has simple tooltip">
  <a href="#">Link 1</a>
</bs:Tooltip>

Sample 1: Tooltip Placement

The Tooltip 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:Tooltip Placement="Left" Title="This element has simple tooltip">
  <a href="#">Link 1</a>
</bs:Tooltip>

<bs:Tooltip Placement="Right" Title="This element has simple tooltip">
  <a href="#">Link 2</a>
</bs:Tooltip>

<bs:Tooltip Placement="Bottom" Title="This element has simple tooltip">
  <a href="#">Link 3</a>
</bs:Tooltip>

<bs:Tooltip Placement="Top" Title="This element has simple tooltip">
  <a href="#">Link 4</a>
</bs:Tooltip>

Sample 3: Tooltip Animation, Delay and Container

The Tooltip 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 tooltip is created. It allows to position the popover in the flow of the document near the triggering element which will prevent the tooltip from floating away from the triggering element during a window resize.

<bs:Tooltip Title="Title" EnableAnimation="false">
    <bs:Button Text="Text" Type="Danger" />
</bs:Tooltip>

<bs:Tooltip Title="Title" Delay="1">
    <bs:Button Text="Text" Type="Info" />
</bs:Tooltip>

<bs:Tooltip Title="Title" Container="body">
    <bs:Button Text="Text" Type="Primary" />
</bs:Tooltip>

Sample 4: Allowing HTML in Title

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

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

<bs:Tooltip Title="{value: TitleHtml}" 
            AllowHtml="true">
    <bs:Button Text="Text" Type="Success" />
</bs:Tooltip>
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>";
    }
}

Sample 5: HTML sanitization

All HTML passed into Tooltip by default goes through throught Bootsraps HTML sanitizer.
HTML sanitizer filters out all non whitelisted tags and attributes.
List of allowed tags and attributes.

To disable HTML sanitization you must set AllowHtmlSanitization to false.

Without sanitization you could have be volnurable to XSS attacks.

<bs:Tooltip Title="{value: TitleHtml}" 
            AllowHtml="true"
            AllowHtmlSanitization="false" >
    <bs:Button Text="Text" Type="Success" />
</bs:Tooltip>
using DotVVM.Framework.ViewModel;

namespace DotvvmWeb.Views.Docs.Controls.bootstrap.Popover.sample5
{
    public class ViewModel : DotvvmViewModelBase
    {
        public string TitleHtml { get; set; } = "<h3 style='color: forestgreen;' >Title with html</h3>";
    }
}

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