--- title: Tooltip description: Use Tooltip to display brief, informative messages when users hover over or focus on elements. --- ```html Hover or focus A Tooltip ``` ## Initialization All elements with classname `env-tooltip` and one child element with `role="tooltip"` will be automatically initialized on `DOMContentLoaded`. Elements with other classnames and elements added to the DOM after document was loaded must be initialized from script. A child element with `role="tooltip"` is required. ```javascript // Initialize elements added after DOMContentLoaded envision.tooltip(); ``` **Note:** HTML is not allowed inside the tooltip. For advanced content, please use [Popover Tooltip](/components/popover/#tooltip). ## Configuration Use data-attributes or option parameters in JavaScript for settings. See [available options below](#options). ### Example using data-attributes ```html
Minimum of 8 characters
``` ### Example using JavaScript ```html Description of the button ``` #### Initialization of JavaScript example ```javascript const tooltipEl = document.querySelectorAll('.example-custom-init-tooltip'); if (tooltipEl) { envision.tooltip(tooltipEl, { placement: 'right', delay: 300, }); } ``` ## Options `envision.tooltip` takes two parameters: ```javascript envision.tooltip(element, options); ``` - `element` - You may pass any selector as a string, a DOM node or node list. Leave empty to initialize all new elements with class `env-tooltip`. - `options` - _{ placement, delay }_ - `placement` _string_ - Prefered initial placement. - Default value: `top` - Possible values: `top`, `right`, `bottom`, `left`, `auto`, - Possible value modifiers: `{value}-start`, `{value}-end` - `delay` _number_ - Milliseconds for delaying the popover opening and closing. - Default value: `200`