Auto-positioning โข Touch Support โข Lightweight โข TypeScript
Quick Start โข Features โข Examples โข Full Docs โข Live Demo
npm install vue3-tooltipor
yarn add vue3-tooltip<!-- Simple as this ๐ -->
<button v-tooltip.auto.touch.primary:top="'Hello World! ๐'">
Hover or tap me
</button>3 seconds to install โข Auto-positioning โข Touch support โข Full TypeScript โข 3.9 KB only
Why developers love Vue3 Tooltip
|
๐ฏ
Smart Auto-Positioning Automatically adjusts position to stay within viewport. Never goes off-screen! |
๐ฑ
Touch Device Support Perfect on mobile & tablets. Tap to show, tap outside to hide. |
โก
Lightweight Only ~3.9 KB gzipped. Zero dependencies! |
|
๐จ
Fully Customizable All styles via CSS variables. Match any design system easily. |
๐ง
TypeScript First Full TypeScript support. Exported types & utilities. |
๐
Easy to Use Simple directive or component. Works out of the box! |
Get up and running in 60 seconds!
Choose your favorite package manager:
npm install vue3-tooltip
# or
yarn add vue3-tooltip
# or
pnpm add vue3-tooltipAdd to your Vue app (usually main.ts or main.js):
import { createApp } from 'vue';
import VueTooltip from 'vue3-tooltip';
import 'vue3-tooltip/tooltip.css'; // ๐ Don't forget styles!
const app = createApp(App);
app.use(VueTooltip); // ๐ Registers directive & component
app.mount('#app');Option A: As a directive (simplest way)
<button v-tooltip="'Hello World!'">
Hover me ๐
</button>Option B: As a component (more control)
<Tooltip>
<template #text>Hover me ๐</template>
<template #tooltip>Hello World!</template>
</Tooltip>That's it! ๐ You're ready to go!
The tooltip automatically flips to stay visible in viewport:
<button v-tooltip.auto:bottom="'I adjust my position smartly!'">
Near screen edge ๐ฏ
</button>๐ก Perfect for dropdowns near screen edges - no more cut-off tooltips!
Works seamlessly on mobile and tablets:
<button v-tooltip.touch="'Tap me on mobile! ๐ฑ'">
Mobile & Desktop Ready
</button>๐ก Automatically detects touch devices and adapts behavior
Choose from three beautiful built-in themes:
<button v-tooltip.primary="'Clean & modern'">Primary</button>
<button v-tooltip.secondary="'Subtle & elegant'">Secondary</button>
<button v-tooltip.accent="'Bold & bright'">Accent</button>Place tooltips exactly where you want them:
<button v-tooltip:top="'โ Top'">Top</button>
<button v-tooltip:bottom="'โ Bottom'">Bottom</button>
<button v-tooltip:left="'โ Left'">Left</button>
<button v-tooltip:right="'โ Right'">Right</button>Mix and match modifiers for powerful tooltips:
<!-- Auto-positioning + Touch + Custom color -->
<button v-tooltip.auto.touch.secondary:top="'The ultimate tooltip! ๐'">
All Features Combined
</button>๐ก Pro tip: Chain modifiers like
.auto.touch.primaryfor maximum functionality!
For more complex scenarios, use the <Tooltip> component:
| Prop | Type | Default | Description |
|---|---|---|---|
position |
'top' | 'bottom' | 'left' | 'right' |
'bottom' |
Tooltip placement |
autoPosition |
boolean |
false |
๐ Auto-adjust to viewport |
adaptiveTouch |
boolean |
false |
๐ Enable touch support |
clickable |
boolean |
false |
Keep open on hover |
disable |
boolean |
false |
Disable tooltip |
Perfect for complex HTML content:
<template>
<Tooltip
position="top"
:auto-position="true"
:adaptive-touch="true"
>
<template #text>
<button class="my-button">
๐ View Stats
</button>
</template>
<template #tooltip>
<div class="rich-tooltip">
<h4>๐ User Statistics</h4>
<p>Active users: <strong>1,234</strong></p>
<p>Growth: <strong style="color: #10b981">+15%</strong></p>
</div>
</template>
</Tooltip>
</template>
<style scoped>
.rich-tooltip {
min-width: 200px;
text-align: left;
}
.rich-tooltip h4 {
margin: 0 0 8px;
font-size: 14px;
}
.rich-tooltip p {
margin: 4px 0;
font-size: 12px;
}
</style>Match your design system effortlessly with CSS variables!
/* In your global CSS */
:root {
/* Make tooltips match your brand */
--tooltip-primary-background: #2563eb;
--tooltip-primary-color: white;
--tooltip-d-border-radius: 12px;
--tooltip-d-padding: 8px 16px;
}๐ Click to see all CSS variables
:root {
/* ๐ Layout & Positioning */
--tooltip-d-z-index: 9999;
--tooltip-d-z-index-hover: 9998;
--tooltip-d-offset: 10px;
/* ๐จ Appearance */
--tooltip-d-padding: 6px 12px;
--tooltip-d-border-radius: 6px;
--tooltip-d-font-size: 14px;
--tooltip-d-font-weight: 500;
--tooltip-d-line-height: 1.4;
/* ๐ฏ Primary Theme */
--tooltip-primary-background: #ffffff;
--tooltip-primary-color: #1a1a1a;
--tooltip-primary-border: 1px solid #e5e5e5;
--tooltip-primary-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
/* ๐จ Secondary Theme */
--tooltip-secondary-background: #f3f4f6;
--tooltip-secondary-color: #374151;
/* โจ Accent Theme */
--tooltip-accent-background: #10b981;
--tooltip-accent-color: #ffffff;
/* โฑ๏ธ Animations */
--tooltip-d-transition-duration: 0.3s;
--tooltip-d-transition-timing: cubic-bezier(0.4, 0, 0.2, 1);
}Dark theme:
:root {
--tooltip-primary-background: #1f2937;
--tooltip-primary-color: #f9fafb;
--tooltip-primary-border: 1px solid #374151;
}Glassmorphism:
:root {
--tooltip-primary-background: rgba(255, 255, 255, 0.8);
--tooltip-primary-backdrop-filter: blur(10px);
--tooltip-primary-border: 1px solid rgba(255, 255, 255, 0.3);
}๐ Full documentation: See DOCS.md for complete customization guide
Full type safety with exported types and utilities:
import type { Position, Rect, TooltipOptions } from 'vue3-tooltip';
import { getBestPosition, isTouchDevice } from 'vue3-tooltip';
// โ
Type-safe position
const position: Position = 'bottom';
// โ
Detect touch devices
const isTouch = isTouchDevice();
// โ
Smart positioning for custom tooltips
const bestPos = getBestPosition(
triggerRect,
tooltipRect,
'bottom'
);Build custom tooltip solutions with our utilities:
import {
getBestPosition, // ๐ฏ Find optimal position
checkPosition, // โ
Validate position fits
isTouchDevice, // ๐ฑ Detect touch support
getRect, // ๐ Get element bounds
checkOverflow // ๐ Check viewport overflow
} from 'vue3-tooltip';Example - Custom tooltip positioning:
import { getBestPosition, getRect } from 'vue3-tooltip';
// Get element rectangles
const triggerRect = getRect(buttonElement);
const tooltipRect = getRect(tooltipElement);
// Find best position automatically
const bestPosition = getBestPosition(
triggerRect,
tooltipRect,
'top' // preferred position
);
console.log(bestPosition); // 'top' or alternative if top doesn't fitComparison with other popular tooltip libraries:
| Feature | Vue3 Tooltip | Others |
|---|---|---|
| ๐ฏ Auto-positioning | โ Built-in | โ Manual |
| ๐ฑ Touch support | โ Adaptive | โ Desktop only |
| ๐ง TypeScript | โ Full support | |
| ๐ฆ Bundle size | โ 3.9 KB | โ 10-20 KB |
| ๐จ CSS Variables | โ Fully customizable | |
| ๐ฆ Dependencies | โ Zero | โ Multiple |
| ๐ณ Tree-shakeable | โ Yes | |
| โก Vue 3 native | โ Built for Vue 3 |
Works everywhere modern Vue 3 works:
|
Chrome |
Firefox |
Safari |
Edge |
iOS Safari |
Samsung |
| 90+ | 88+ | 14+ | 90+ | 14+ | โ |
|
๐ Complete Documentation Full API reference, examples, and guides |
๐ Changelog Version history and migration guides |
๐ฎ Live Demo Try it in an interactive playground |
We welcome contributions! Help us make tooltips better for everyone.
# 1๏ธโฃ Clone the repository
git clone https://github.com/neluckoff/vue3-tooltip.git
cd vue3-tooltip
# 2๏ธโฃ Install dependencies
npm install
# 3๏ธโฃ Run tests (watch mode)
npm test
# 4๏ธโฃ Build the library
npm run build
# 5๏ธโฃ Test locally in your project
npm link- ๐ Report bugs - Open an issue
- โจ Suggest features - Request a feature
- ๐ Improve docs - Fix typos, add examples
- ๐งช Add tests - Increase coverage
- ๐จ Design - Suggest UX improvements
- ๐ป Code - Submit pull requests
- ๐ก๏ธ Security - Report vulnerabilities privately
๐ Please read our Contributing Guide before submitting PRs
๐ค By participating, you agree to our Code of Conduct
๐ Found a security issue? See our Security Policy
Released under the MIT License
Copyright ยฉ 2025 Dmitrii Lukianenko
Created by @neluckoff
GitHub โข NPM โข Share on TwitterIf you find a bug or have a feature request, please open an issue ๐