Preview
Tooltip as a Directive
Usage
Default
Default tooltip directive uses top as default placement
With Placement
It's possible to change the tooltip default placement with directive arguments, possible values: bottom, bottom-start, bottom-end, right, right-start, right-end, left, left-start, left-end, top, top-start, top-end.
With Object Syntax
It's possible to change any property of the tooltip with object syntax.
Content Mode
Tooltip content renders outside the DOM tree via Tippy.js. Use the contentMode modifier or object property to apply a color mode to the tooltip content. See Positioned Components for details.
Import
Import the directive from dialtone-vue
import { DtTooltipDirective } from "@dialpad/dialtone-vue";
Install the directive into vue instance
Vue.use(DtTooltipDirective);
Tooltip as a Component
The tooltip, also known as infotip or hint, is a common graphical user interface element in which, when hovering over a screen element or component, a text box displays information about that element (such as a description of a button's function, or what an abbreviation stands for). The tooltip is displayed continuously as long as the user hovers over the element.
When placing DtTooltip on a disabled DtButton, wrap the button in a <span> element — disabled elements do not fire mouse events, so the tooltip anchor must be on the wrapper, not on the disabled button itself.
A tooltip has two slots:
- the anchor required slot
- the default slot (which could be replaced with prop message)
Base Styles
Placement
External anchor
Fallback Placements
The tooltip uses headless-tippy and popper, if the tooltip opens in a placement where it will be clipped, it will move to a new position. It will do this automatically by default, but if you want to manually specify which position it will move to in what order you can do so via the fallbackPlacements prop.
Content Mode
Tooltip content renders outside the DOM tree via Tippy.js. Use the contentMode prop to apply a color mode to the tooltip content. See Positioned Components for details.
Vue API
import { DtTooltip } from '@dialpad/dialtone-vue';Slots
Props
Events
Classes
Accessibility
Reads out the tooltip content as a supplementary description for its trigger when the trigger is focused. See also wai aria practices 1.1.
Anchor
The anchor element that activates the tooltip should be fully accessible by keyboard. The easiest way to do this is by
using an element like an DtButton that is already accessible. When pressing the ESC key in a focused tooltip,
tooltip will be closed.
There are some required ARIA attributes for the anchor element (such as aria-hidden set based on open).
To make this as straightforward as possible, these ARIA attributes are passed
with the correct values as the attrs to the anchor slot. Applying them is as simple as using v-bind.
Focus & Keyboard
Due to the different contexts in which a tooltip can be used, focus management and
keyboard shortcut ESC is provided.
You are encouraged to consult the ARIA documentation for the particular role.