Easy tooltips, popovers and dropdowns for Vue 2.x with Popper.js integration
npx @tessl/cli install tessl/npm-v-tooltip@2.1.0v-tooltip provides easy-to-use tooltips, popovers, and dropdowns for Vue 2.x applications with Popper.js integration. It offers both directive-based and component-based approaches for creating interactive tooltips with extensive customization options, positioning control, and support for complex content including Vue components.
npm install v-tooltipimport Vue from 'vue';
import VTooltip from 'v-tooltip';
Vue.use(VTooltip);For direct imports:
import { VTooltip, VPopover, VClosePopover } from 'v-tooltip';
Vue.directive('tooltip', VTooltip);
Vue.directive('close-popover', VClosePopover);
Vue.component('v-popover', VPopover);For browser usage:
<script src="https://unpkg.com/v-tooltip@^2.0.0"></script>
<script>
// Auto-installs if Vue is detected globally
// Or manually install:
Vue.use(VTooltip);
</script><template>
<div>
<!-- Simple tooltip -->
<button v-tooltip="'Hello World!'">Hover me</button>
<!-- Popover with content -->
<v-popover>
<button>Click me</button>
<template slot="popover">
<h3>Popover Title</h3>
<p>Complex content goes here</p>
</template>
</v-popover>
</div>
</template>v-tooltip is built around several key components:
v-tooltip directive for simple tooltip functionalityVPopover component for complex interactive contentSimple tooltip functionality using the v-tooltip directive. Supports string content, positioning modifiers, and configuration objects.
// Basic string tooltip
v-tooltip="tooltipContent"
// With positioning modifier
v-tooltip.bottom-start="tooltipContent"
// With configuration object
v-tooltip="{ content: 'text', placement: 'top', delay: 500 }"Advanced popover functionality with Vue component slots for complex interactive content.
// Component registration
Vue.component('v-popover', VPopover);
// Component props
interface VPopoverProps {
open?: boolean;
disabled?: boolean;
placement?: string;
delay?: string | number | object;
trigger?: string;
// ... additional props
}System-wide configuration options for default behavior and styling.
// Plugin options during installation
Vue.use(VTooltip, options);
// Direct configuration
VTooltip.options.defaultClass = 'my-tooltip';
VTooltip.enabled = window.innerWidth > 768;Direct access to the underlying Tooltip class for advanced use cases.
import { createTooltip, destroyTooltip } from 'v-tooltip';
function createTooltip(el: HTMLElement, value: any, modifiers?: object): Tooltip;
function destroyTooltip(el: HTMLElement): void;interface DelayConfig {
show?: number;
hide?: number;
}
interface VTooltipPlugin {
install(Vue: any, options?: Partial<GlobalVTooltipOptions>): void;
enabled: boolean;
options: GlobalVTooltipOptions;
}
interface GlobalVTooltipOptions {
defaultPlacement: string;
defaultClass: string;
defaultTargetClass: string;
defaultHtml: boolean;
defaultTemplate: string;
defaultArrowSelector: string;
defaultInnerSelector: string;
defaultDelay: number | DelayConfig;
defaultTrigger: string;
defaultOffset: number | string;
defaultContainer: string | HTMLElement | false;
defaultBoundariesElement: string | HTMLElement;
defaultPopperOptions: any;
defaultLoadingClass: string;
defaultLoadingContent: string;
autoHide: boolean;
defaultHideOnTargetClick: boolean;
disposeTimeout: number;
popover: Partial<GlobalVTooltipPopoverOptions>;
}
interface GlobalVTooltipPopoverOptions {
defaultPlacement: string;
defaultClass: string;
defaultBaseClass: string;
defaultWrapperClass: string;
defaultInnerClass: string;
defaultArrowClass: string;
defaultOpenClass: string;
defaultDelay: number | DelayConfig;
defaultTrigger: string;
defaultOffset: number | string;
defaultContainer: string | HTMLElement | false;
defaultBoundariesElement: string | HTMLElement;
defaultPopperOptions: any;
defaultAutoHide: boolean;
defaultHandleResize: boolean;
}