---
title: "vTooltip"
description: "vTooltip is a Vue directive to display a text when the user hovers an element"
package: "maz-ui"
url: "https://maz-ui.com/directives/tooltip"
---
# vTooltip
> vTooltip is a Vue directive to display a text when the user hovers an element
- Package: `maz-ui`
- Import: `import { vTooltip } from 'maz-ui/directives/vTooltip'`
- Web: https://maz-ui.com/directives/tooltip
## Basic usage
```vue
Top
Right
Left
Bottom
```
## Colors
```html
Primary
Secondary
Success
Warning
destructive
Info
Accent
Contrast
Background
```
## Position
You can change the position of the tooltip by passing a `position` option or using the directive modifier (e.g. `v-tooltip.top`).
```html
Bottom
Left
Right
Top
Top start
Top end
Bottom start
Bottom end
```
## HTML content
You can also use HTML content in the tooltip by passing a string to the `html` option.
```html
HTML
```
## Customization
You can customize the tooltip by passing a `panelClass` or `panelStyle` option.
```html
panelClass
panelStyle
```
## Trigger
You can change the trigger mode of the tooltip by passing a `trigger` option.
The default trigger is `hover`.
The `adaptive` trigger will use the `click` trigger on touch devices (mobile and tablet) and the `hover` trigger on non-touch devices (desktop).
```html
Click
Hover
Adaptive
```
## Offset
The `offset` (in px) option allows you to adjust the position of the tooltip relative to the original element.
```html
0
10
20
40
```
## Open programmatically
```vue
Primary
Toggle tooltip
```
## Conditionally disable
Pass `false`, `null` or `undefined` as the binding value to silently disable the tooltip - no popover instance is created, no listeners are attached, and no warning is logged. This is the recommended way to skip the tooltip on the fly without conditionally rendering two different elements:
```vue
Hover me
```
If the binding switches back to a valid value later, the tooltip mounts as expected. Toggling the value off again destroys the existing popover instance.
## Global install
### Vue
```typescript
import { vTooltipInstall } from 'maz-ui/directives'
import { createApp } from 'vue'
const app = createApp(App)
// Options are optional
app.use(vTooltipInstall, {
position: 'top',
color: 'primary',
})
app.mount('#app')
```
### Nuxt
Please refer to the [Nuxt module documentation](../ecosystem/nuxt.md) for more information.
## Types
```ts
interface VTooltipOptions extends Partial> {
/**
* Text to display in the tooltip
*/
text?: string
/**
* HTML content (alternative to text)
*/
html?: string
/**
* Color variant of the tooltip
* @default default
*/
color?: MazPopoverProps['color']
/**
* Position of the tooltip
* @default top
*/
position?: PopoverPosition
/**
* Trigger of the tooltip
* @default hover
*/
trigger?: MazPopoverTrigger
/**
* Close on click outside
* @default false
*/
closeOnClickOutside?: boolean
/**
* Close on escape
* @default false
*/
closeOnEscape?: boolean
/**
* Open the tooltip
* @default false
*/
open?: boolean
}
type VTooltipBindingValue
= | string
| VTooltipOptions
```