itc-hover
v1.0.0
Published
A flexible hover component for Vue 3 + Quasar with tooltip and hover effect support
Downloads
1
Maintainers
Readme
ITC Hover Package
A flexible hover and tooltip component for Vue 3 + Quasar applications. Easily add tooltips to any element with full control over positioning, styling, delay, and behavior using Quasar's powerful tooltip system.
Features
- ✅ Vue 3 with Composition API
- ✅ Quasar Framework integration - Uses Quasar's
q-tooltipcomponent - ✅ Simple API - Just wrap your element and pass props
- ✅ Flexible Positioning - Control anchor, self, offset with 9 position options
- ✅ Custom Styling - Custom classes, styles, and transitions
- ✅ HTML Support - Render HTML content in tooltips
- ✅ Delay Control - Custom delay before showing tooltip
- ✅ All Quasar Tooltip Props - Support for all Quasar tooltip features
- ✅ Dual Format Build - ES Modules and CommonJS
Philosophy
Props-Based Configuration:
Hover Component → Quasar q-tooltip → Rendered TooltipInstead of manually configuring Quasar tooltips, wrap your elements with Hover component and pass props to control all tooltip behavior.
Getting Started
Prerequisites
- Node.js 18+ or 20+
- npm or pnpm
- Vue 3.5.25+
- Quasar 2.18.6+
Installation
Install the package:
npm install itc-hover # or pnpm add itc-hoverUse in your project:
<script setup> import { Hover } from 'itc-hover' </script> <template> <Hover text="This is a tooltip"> <q-btn label="Hover me" /> </Hover> </template>
Usage
Basic Example
<template>
<Hover text="Help information">
<q-btn icon="help_outline" flat round />
</Hover>
</template>
<script setup>
import { Hover } from 'itc-hover'
</script>With Positioning
<template>
<Hover
text="Click to change tag"
anchor="bottom right"
self="top right"
>
<q-chip label="Tag" />
</Hover>
</template>With HTML Content
<template>
<Hover
text="Click to change <strong>'Tag Name'</strong> tag"
:html="true"
anchor="bottom right"
self="top right"
>
<q-chip label="HTML Tag" />
</Hover>
</template>With Custom Delay
<template>
<Hover
text="This tooltip appears after 1 second"
:delay="1000"
>
<q-btn label="Delayed Tooltip" />
</Hover>
</template>With Custom Styling
<template>
<Hover
text="Points Information"
tooltip-class="bg-grey-9"
transition-show="scale"
transition-hide="scale"
>
<q-btn icon="info" />
</Hover>
</template>API Reference
Hover Component Props
Content Props
| Prop | Type | Default | Description |
|------|------|---------|-------------|
| text | String | null | Tooltip text content (alternative to tooltip) |
| tooltip | String | null | Tooltip text content (alternative to text) |
| html | Boolean | false | Render text as HTML (alternative to tooltipHtml) |
| tooltipHtml | Boolean | false | Render text as HTML (alternative to html) |
| showTooltip | Boolean | true | Show/hide tooltip |
Positioning Props
| Prop | Type | Default | Description |
|------|------|---------|-------------|
| anchor | String | undefined | Position of tooltip relative to trigger (alternative to tooltipAnchor) |
| tooltipAnchor | String | 'bottom middle' | Position of tooltip relative to trigger (alternative to anchor) |
| self | String | undefined | Position of tooltip itself (alternative to tooltipSelf) |
| tooltipSelf | String | 'top middle' | Position of tooltip itself (alternative to self) |
| offset | Array | undefined | Offset [x, y] in pixels (alternative to tooltipOffset) |
| tooltipOffset | Array | [10, 10] | Offset [x, y] in pixels (alternative to offset) |
Valid Anchor/Self Values:
'top left','top middle','top right''center left','center middle','center right''bottom left','bottom middle','bottom right'
Behavior Props
| Prop | Type | Default | Description |
|------|------|---------|-------------|
| delay | Number | undefined | Delay before showing tooltip in milliseconds (alternative to tooltipDelay) |
| tooltipDelay | Number | undefined | Delay before showing tooltip in milliseconds (alternative to delay) |
| maxWidth | String | undefined | Maximum width of tooltip (alternative to tooltipMaxWidth) |
| tooltipMaxWidth | String | '200px' | Maximum width of tooltip (alternative to maxWidth) |
| transitionShow | String | undefined | Transition when showing (alternative to tooltipTransitionShow) |
| tooltipTransitionShow | String | 'fade' | Transition when showing (alternative to transitionShow) |
| transitionHide | String | undefined | Transition when hiding (alternative to tooltipTransitionHide) |
| tooltipTransitionHide | String | 'fade' | Transition when hiding (alternative to transitionHide) |
Styling Props
| Prop | Type | Default | Description |
|------|------|---------|-------------|
| tooltipClass | String | '' | Additional CSS class for tooltip |
| style | String/Object | {} | Inline styles for tooltip (alternative to tooltipStyle) |
| tooltipStyle | String/Object | {} | Inline styles for tooltip (alternative to style) |
Advanced Quasar Tooltip Props
| Prop | Type | Default | Description |
|------|------|---------|-------------|
| noParentEvent | Boolean | false | Prevent tooltip from closing when clicking parent |
| tooltipNoParentEvent | Boolean | false | Prevent tooltip from closing when clicking parent |
| fit | Boolean | false | Fit tooltip within viewport |
| tooltipFit | Boolean | false | Fit tooltip within viewport |
| cover | Boolean | false | Tooltip covers the target element |
| tooltipCover | Boolean | false | Tooltip covers the target element |
| persistent | Boolean | false | Tooltip stays visible until manually closed |
| tooltipPersistent | Boolean | false | Tooltip stays visible until manually closed |
| scrollTarget | String/Object | undefined | Custom scroll target element/selector |
| tooltipScrollTarget | String/Object | undefined | Custom scroll target element/selector |
| touchPosition | Boolean | false | Use touch position on mobile devices |
| tooltipTouchPosition | Boolean | false | Use touch position on mobile devices |
Slots
| Slot | Description |
|------|-------------|
| default | Element to wrap with tooltip |
Examples
Simple Button Tooltip
<template>
<Hover text="Time Entries">
<q-btn icon="o_timer" flat round />
</Hover>
</template>
<script setup>
import { Hover } from 'itc-hover'
</script>Chip with Tag Change Tooltip
<template>
<Hover
text="Click to change 'Tag Name' tag"
:html="true"
anchor="bottom right"
self="top right"
>
<q-chip label="Tag" />
</Hover>
</template>
<script setup>
import { Hover } from 'itc-hover'
</script>Icon with Dynamic Tooltip
<template>
<Hover :text="user.email">
<q-btn icon="email" flat round />
</Hover>
</template>
<script setup>
import { Hover } from 'itc-hover'
import { ref } from 'vue'
const user = ref({ email: '[email protected]' })
</script>Dark Background Tooltip
<template>
<Hover
text="Change Image"
tooltip-class="bg-dark"
>
<q-btn icon="image" />
</Hover>
</template>
<script setup>
import { Hover } from 'itc-hover'
</script>Scale Transition Tooltip
<template>
<Hover
text="Points Information"
tooltip-class="bg-grey-9"
transition-show="scale"
transition-hide="scale"
anchor="bottom middle"
self="bottom middle"
>
<q-btn icon="info" />
</Hover>
</template>
<script setup>
import { Hover } from 'itc-hover'
</script>With Custom Delay and Offset
<template>
<Hover
text="This tooltip appears after 1 second"
:delay="1000"
:offset="[20, 20]"
>
<q-btn label="Delayed Tooltip" />
</Hover>
</template>
<script setup>
import { Hover } from 'itc-hover'
</script>Persistent Tooltip
<template>
<Hover
text="This tooltip stays visible"
:persistent="true"
>
<q-btn label="Persistent Tooltip" />
</Hover>
</template>
<script setup>
import { Hover } from 'itc-hover'
</script>Building
Build for Production
BUILD_LIB=true npm run build
# or
BUILD_LIB=true pnpm run buildThis will:
- Compile JavaScript
- Bundle Vue components
- Generate both ES Modules (
.js) and CommonJS (.cjs) formats - Output to
dist/directory
Build Output Structure
dist/
├─ itc-hover.js # ES Module
└─ itc-hover.cjs # CommonJSDevelopment Build (Watch Mode)
BUILD_LIB=true npm run devChanges will rebuild automatically. Restart your test project's dev server to pick up changes.
Testing Locally
Option 1: Using npm link
In your package directory:
npm linkIn your test project:
npm link itc-hover
Option 2: Using File Path
In your test project's
package.json:{ "dependencies": { "itc-hover": "file:../itc-hover" } }Install:
npm install
Development Workflow
For active development with auto-rebuild:
BUILD_LIB=true npm run devChanges will rebuild automatically. Restart your test project's dev server to pick up changes.
Publishing to npm
Before Publishing
Update
package.json:- Verify
nameis unique on npm - Update
version(follow semver) - Verify
filesarray includes onlydist:{ "files": ["dist"] }
- Verify
Build the package:
BUILD_LIB=true npm run buildTest the build locally (see Testing Locally section above)
Publishing Steps
Step 1: Enable 2FA or Create Access Token
Option A: Enable 2FA on npm (Recommended)
- Go to https://www.npmjs.com/settings/itcroja/security
- Enable Two-Factor Authentication (2FA)
- Follow the setup process (use authenticator app like Google Authenticator)
- Once enabled, you can publish with 2FA code
Option B: Create Granular Access Token (Alternative)
Go to https://www.npmjs.com/settings/itcroja/tokens
Click Generate New Token → Granular Access Token
Set permissions:
- Type: Automation
- Packages: Select
itc-hoveror all packages - Permissions: Read and Write
- Expiration: Set as needed
Copy the token (starts with
npm_)Use token for authentication:
npm config set //registry.npmjs.org/:_authToken YOUR_TOKEN_HERE
Step 2: Login to npm
npm loginIf using 2FA, you'll be prompted for the 2FA code during login.
Step 3: Verify you're logged in
npm whoamiStep 4: Check what will be published
npm pack --dry-runStep 5: Publish
npm publish --access publicNote: If you have 2FA enabled, you may need to use npm publish --otp=YOUR_2FA_CODE or set up automation token.
- Verify on npm:
Visit
https://www.npmjs.com/package/itc-hover
Version Management
Use npm version commands to bump versions:
# Patch version (1.0.0 → 1.0.1)
npm version patch
# Minor version (1.0.0 → 1.1.0)
npm version minor
# Major version (1.0.0 → 2.0.0)
npm version majorThen publish:
npm publish --access publicConfiguration
External Dependencies
By default, vue and quasar are marked as external (not bundled). The package expects these to be provided by the consuming application.
Quasar Components Required
Ensure QTooltip component is registered in your Quasar config:
// quasar.config.js
framework: {
components: [
'QTooltip'
]
}Best Practices
- ✅ Use peer dependencies for Vue and Quasar (provided by consumer)
- ✅ Use
textprop for simple tooltips (shorter syntax) - ✅ Use
htmlprop when you need HTML formatting in tooltip - ✅ Set appropriate delays for better UX (default 500ms works well)
- ✅ Use positioning props (
anchor,self) for better tooltip placement - ✅ Leverage Quasar classes for styling via
tooltip-classprop - ❌ Don't bundle Vue or Quasar into the package
- ❌ Don't use both
textandtooltipprops at the same time (use one) - ❌ Don't use both
htmlandtooltipHtmlprops at the same time (use one)
Troubleshooting
Component Not Found Errors
- "Failed to resolve component: q-tooltip": Register
QTooltipcomponent inquasar.config.js
Build Errors
- "Rollup failed to resolve import": Add the package to
externalinvite.config.ts - "Cannot find module": Ensure package is built (
BUILD_LIB=true npm run build)
Import Errors in Test Project
- Ensure the package is built (
BUILD_LIB=true npm run build) - Check
package.jsonexports are correct - Verify the import path matches your exports
- Clear node_modules and reinstall
Tooltip Not Showing
- Verify
textortooltipprop is provided - Check that
showTooltipis notfalse - Ensure Quasar
QTooltipcomponent is registered - Check browser console for errors
Delay Not Working
- Ensure you're using Quasar's default delay behavior (no manual implementation needed)
- Check that delay value is a number (in milliseconds)
- Verify tooltip is not being blocked by other elements
License
MIT
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Build and test locally
- Submit a pull request
Happy coding! 🚀
