๐ŸŽฏ ngx-smart-tooltip

December 22, 2025 ยท View on GitHub

A modern, lightweight, and customizable tooltip library for Angular 18+. Built with Signals, Web Animations API, and OnPush strategy for maximum performance.

npm version License

โœจ Features

  • ๐Ÿš€ Modern: Built with Angular Signals and Standalone Directives.
  • โšก Fast: Uses OnPush change detection and Web Animations API (no heavy generic animation modules).
  • ๐ŸŽจ Premium Design: Beautiful, responsive tooltips with rotatable square arrows that support borders and shadows.
  • ๐Ÿงฉ Zero Dependencies: No popper.js or floating-ui. Self-contained positioning engine.
  • โ™ฟ Accessible: Manages aria attributes automatically.
  • โœจ Animated: smooth fade, scale, and slide animations out of the box.

๐Ÿ“ฆ Installation

npm install ngx-smart-tooltip

๐Ÿš€ Usage

Since ngx-smart-tooltip is standalone, you simply import TooltipDirective into your component or app.config.ts.

1. Import

import { Component } from '@angular/core';
import { TooltipDirective } from 'ngx-smart-tooltip';

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [TooltipDirective], // <--- Import here
  template: `
    <button [ngxTooltip]="'Hello World'">Hover Me</button>
  `
})
export class AppComponent {}

2. Basic Examples

<!-- Simple text -->
<button [ngxTooltip]="'Simple Tooltip'">Hover Me</button>

<!-- With configuration -->
<button 
  [ngxTooltip]="'Bottom placement'" 
  tooltipPosition="bottom" 
  tooltipTheme="light">
  Configuration
</button>

<!-- Rich Content using TemplateRef -->
<ng-template #myTemplate>
  <strong>Bold Text</strong> and <em>Italic</em>
  <img src="icon.png" />
</ng-template>

<button [ngxTooltip]="myTemplate">Rich Content</button>

โš™๏ธ Configuration

InputTypeDefaultDescription
[ngxTooltip]string | TemplateRef''Required. The content to display.
[tooltipPosition]'top' | 'bottom' | 'left' | 'right' | 'auto''top'Preferred position. Supports start/end (e.g. top-start).
[tooltipTrigger]'hover' | 'click' | 'focus' | 'manual''hover'Interaction that triggers the tooltip.
[tooltipTheme]'dark' | 'light' | 'custom''dark'Visual theme.
[tooltipAnimation]'fade' | 'scale' | 'slide' | 'none''fade'Entrance/exit animation style.
[tooltipArrow]booleantrueShow/hide the pointer arrow.
[tooltipShowDelay]number0Delay in ms before showing.
[tooltipHideDelay]number100Delay in ms before hiding.
[tooltipInteractive]booleanfalseIf true, user can hover over the tooltip content itself.
[tooltipMaxWidth]number | string300Max width in pixels (e.g. 200 or '200px').
[tooltipClass]string''Custom CSS class to add to the tooltip container.

๐ŸŽจ Custom Styling

You can create your own themes using the customClass input or by overriding CSS variables.

Example: Gradient Theme

/* global styles or ViewEncapsulation.None */
.my-gradient-tooltip {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

/* Match the arrow to the background */
.my-gradient-tooltip .ngx-tooltip-arrow {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
<button 
  [ngxTooltip]="'Cool Gradient!'" 
  tooltipClass="my-gradient-tooltip">
  Gradient Tooltip
</button>

๐Ÿค Contributing

Contributions are welcome! Please submit a PR or open an issue.

๐Ÿ“„ License

MIT