Angular Bootstrap Tooltips
Angular Tooltips - Bootstrap 4 & Material Design
Note: This documentation is for an older version of Bootstrap (v.4). A
newer version is available for Bootstrap 5. We recommend migrating to the latest version of our product - Material Design for
Bootstrap 5.
Go to docs v.5
Tooltips are a convenient way of presenting additional information to your user. They are tiny little clouds with a brief text message, triggered by clicking on a specified element or hovering over it.
Examples
Hover over the links below to see tooltips:
Tight pants next level keffiyeh
<a href="#" mdbTooltip="Basic tooltip" placement="top">you probably</a>
haven't heard of them. Photo booth beard raw denim letterpress vegan messenger bag stumptown. Farm-to-table
seitan, mcsweeney's fixie sustainable quinoa 8-bit american apparel
<a href="#" mdbTooltip="Another tooltip" placement="top">have a</a>
terry richardson vinyl chambray. Beard stumptown, cardigans banh mi lomo thundercats. Tofu biodiesel
williamsburg marfa, four loko mcsweeney's cleanse vegan chambray. A really ironic artisan
<a href="#" mdbTooltip="Again, basic tooltip" placement="top">whatever keytar</a>
,scenester farm-to-table banksy Austin
<a href="#" mdbTooltip="And the last tooltip" placement="top">twitter handle</a>
freegan cred raw denim single-origin coffee viral.
Now, hover over the buttons below to see the four tooltips directions: top, right, bottom, and left.
<button type="button" mdbBtn color="primary" class="bwaves-light" mdbTooltip="Tooltip on top" placement="top" mdbWavesEffect>
Tooltip on top
</button>
<button type="button" mdbBtn color="primary" class="waves-light" mdbTooltip="Tooltip on right" placement="right" mdbWavesEffect>
Tooltip on right
</button>
<button type="button" mdbBtn color="primary" class="waves-light" mdbTooltip="Tooltip on bottom" placement="bottom" mdbWavesEffect>
Tooltip on bottom
</button>
<button type="button" mdbBtn color="primary" class="waves-light" mdbTooltip="Tooltip on left" placement="left" mdbWavesEffect>
Tooltip on left
</button>
Custom HTML
You can use HTML to customize a tooltip's title.
<ng-template #popTemplate> <div [innerHtml]="html"></div></ng-template>
<button type="button" mdbBtn color="primary" class="waves-light" [mdbTooltip]="popTemplate" mdbWavesEffect>
Tooltip with html
</button>
import { Component} from '@angular/core';
@Component({
selector: 'tooltip-dynamic-example',
templateUrl: 'tooltip-dynamic.html',
})
export class TooltipDynamicComponent {
html = '<span><i>Tooltip</i> <u>with</u> <b>HTML</b></span>';
}
Show and Hide
You can use the show()
and hide()
methods to manually toggle the tooltip. Remember to pass the $event
argument to the show()
function.
This text has attached to it a tooltip
<p>
<span mdbTooltip="Hello there! I was triggered manually" triggers="" #pop="mdb-tooltip">
This text has attached to it a tooltip
</span>
</p>
<button type="button" mdbBtn color="success" class="waves-light" (click)="pop.show($event)" mdbWavesEffect>Show</button>
<button type="button" mdbBtn color="warning" class="waves-light" (click)="pop.hide()" mdbWavesEffect>Hide</button>
Modify tooltip height
Add .tooltip-inner { height: desired-value }
to the styles.scss
stylesheet to change the height of the tooltip.
Also, remember to use a customHeight
input.
This is required if the tooltip has no space to display along the top or bottom edge of the screen, and is displayed the other way round.
<button type="button" mdbBtn color="primary" class="waves-light" customHeight="50" mdbTooltip="Tooltip on top" placement="top" mdbWavesEffect>
Tooltip on top
</button>
<button type="button" mdbBtn color="primary" class="fixed-bottom waves-light" customHeight="50" mdbTooltip="Tooltip on bottom" placement="bottom" mdbWavesEffect>
Tooltip on bottom
</button>
.tooltip-inner {
height: 50px;
line-height: 50px;
}
Angular Tooltips - API
In this section you will find informations about required modules and available inputs, outputs, methods and events of tooltip directive.
Modules used
In order to speed up your application, you can choose to import only the modules you actually need, instead of importing the entire MDB Angular library. Remember that importing the entire library, and immediately afterwards a specific module, is bad practice, and can cause application errors.
import { TooltipModule, ButtonsModule, WavesModule } from 'ng-uikit-pro-standard'
import { TooltipModule, ButtonsModule, WavesModule } from 'angular-bootstrap-md'
Directives
TooltipDirective
Selector: mdbTooltip
Type: TooltipDirective
Inputs
Name | Type | Default | Description | Example |
---|---|---|---|---|
container
|
string | 'body' | A selector specifying the element the tooltip should be appended to; at the present time only supports "body". | container="body" |
isDisabled
|
boolean | false | Allows to disable tooltip. | isDisabled="true" |
isOpen
|
boolean | false | Returns whether or not the tooltip is currently being shown. | isOpen="true" |
placement
|
string | - | Placement of a tooltip; pick one of the accepted options: top, bottom, left, right. | placement="top" |
mdbTooltip
|
string | - | The content of your tooltip. | mdbTooltip="Tooltip content" |
triggers
|
string | 'hover focus' | Specifies the events that will be triggered. Supports a space separated list of event names. | triggers="mouseenter:click" |
delay
|
number | - | Specifies the delay after which tooltip will be fired. | delay="1000" |
customHeight
|
number | - | Specifies the height of the tooltip if was overwritten in scss. Used to determine if tooltip will fit to remaining space or not. | customHeight="50" |
Events
Name | Type | Description | Example |
---|---|---|---|
hidden
|
any | Emits an event when the tooltip is hidden. | (hidden)="onHidden()" |
tooltipChange
|
any | Fired when tooltip content changes. | (tooltipChange)="tooltipChange()" |
shown
|
any | Emits an event when the tooltip is shown. | (shown)="onShown()" |
Methods
Below methods are available in TooltipDirective
Name | Description |
---|---|
show(event?)
|
Opens an element’s tooltip. This is considered a "manual" triggering of the tooltip. |
hide()
|
Closes an element’s tooltip. This is considered a "manual" triggering of the tooltip. |
toggle(value: boolean)
|
Toggles an element’s tooltip. This is considered a “manual” triggering of the tooltip. |