vTooltip
vTooltip is a Vue directive to display a text when the user hovers an element
Basic usage
Hover the buttons
Colors
Hover the buttons
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 content
You can also use HTML content in the tooltip by passing a string to the html option.
Customization
You can customize the tooltip by passing a panelClass or panelStyle option.
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).
Offset
The offset (in px) option allows you to adjust the position of the tooltip relative to the original element.
Open programmatically
Global install
Vue
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 for more information.
Types
interface VTooltipOptions extends Partial<Omit<MazPopoverProps, 'modelValue'>> {
/**
* 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