Tooltips
Materialize is a modern responsive CSS framework based on Material Design by Google.
Tooltips are small, interactive, textual hints for mainly graphical elements. When using icons for actions you can use a tooltip to give people clarification on its function.
Add the Tooltipped class to your element and add either top, bottom, left, right on data-tooltip to control the position.
Hover me!
Also HTML-Elements can be added with the attribute
data-tooltip-id="tooltip-content"
Bottom
Initialization
document.addEventListener('DOMContentLoaded', function() {
var elems = document.querySelectorAll('.tooltipped');
var instances = M.Tooltip.init(elems, {
// specify options here
});
});
Options
Name | Type | Default | Description |
---|---|---|---|
exitDelay | Number | 200 | Delay time before tooltip disappears. |
enterDelay | Number | 0 | Delay time before tooltip appears. |
text | String | Text string for the tooltip. | |
unsafeHTML | String | null |
HTML content that will be appended to to
text . Only use properly sanitized or otherwise trusted data for unsafeHTML .
|
html | String | null |
(DEPRECATED): will be removed in a later release.
HTML content that will be appended to
Will be ignored if
|
margin | Number | 5 | Set distance tooltip appears away from its activator excluding transitionMovement. |
inDuration | Number | 300 | Enter transition duration. |
opacity | Number | 1 | Opacity of the tooltip. |
outDuration | Number | 250 | Exit transition duration. |
position | String | 'bottom' | Set the direction of the tooltip. 'top', 'right', 'bottom', 'left'. |
transitionMovement | Number | 10 | Amount in px that the tooltip moves during its transition. |
Methods
All the methods are called on the plugin instance. You can get the plugin instance like this:
var instance = M.Tooltip.getInstance(elem);
.open();
Show tooltip.
instance.open();
.close();
Hide tooltip.
instance.close();
.destroy();
Destroy plugin instance and teardown
instance.destroy();
Properties
Name | Type | Description |
---|---|---|
el | Element | The DOM element the plugin was initialized with. |
options | Object | The options the instance was initialized with. |
isOpen | Boolean | If tooltip is open. |
isHovered | Boolean | If tooltip is hovered. |