[ Installation ]

npx wally-ui add tooltip

[ Import ]

// app.component.ts or your module file
import { Tooltip } from './components/tooltip/tooltip';
@Component({
  selector: 'app-root',
  imports: [Tooltip],
  // ...
})

[ Basic Usage ]

<wally-tooltip text="This is a tooltip">
  <button>Hover me</button>
</wally-tooltip>

[ Smart Auto-Positioning ]

Auto Position (Default)

Automatically detects viewport space and positions tooltip optimally. Includes overflow detection for edge cases.

<!-- Auto positioning (default) -->
<wally-tooltip text="Auto positioned" position="auto">
  <button>Auto</button>
</wally-tooltip>

<!-- Fixed positions -->
<wally-tooltip text="Always on top" position="top">
  <button>Top</button>
</wally-tooltip>

<wally-tooltip text="Always on bottom" position="bottom">
  <button>Bottom</button>
</wally-tooltip>

<wally-tooltip text="Always on left" position="left">
  <button>Left</button>
</wally-tooltip>

<wally-tooltip text="Always on right" position="right">
  <button>Right</button>
</wally-tooltip>

[ Usage Examples ]

With Button Component

<wally-tooltip text="Save your changes">
  <wally-button variant="primary">Save</wally-button>
</wally-tooltip>

Icon-Only Button

Essential for icon-only buttons to provide context for screen readers and visual users.

<wally-tooltip text="Send message">
  <wally-button [variant]="'ghost'" [rounded]="true" ariaLabel="Send">
    <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-5">
      <path stroke-linecap="round" stroke-linejoin="round" d="M6 12 3.269 3.125A59.769 59.769 0 0 1 21.485 12 59.768 59.768 0 0 1 3.27 20.875L5.999 12Zm0 0h7.5" />
    </svg>
  </wally-button>
</wally-tooltip>

[ Configuration ]

Custom Delay

<!-- Fast tooltip (100ms) -->
<wally-tooltip text="Quick tooltip" [delay]="100">
  <button>Fast</button>
</wally-tooltip>

<!-- Slow tooltip (500ms) -->
<wally-tooltip text="Delayed tooltip" [delay]="500">
  <button>Slow</button>
</wally-tooltip>

Disabled State

<wally-tooltip text="This won't show" [disabled]="true">
  <button>Disabled Tooltip</button>
</wally-tooltip>

Custom Offset

<!-- More spacing from element -->
<wally-tooltip text="More space" [offset]="4">
  <button>Large offset</button>
</wally-tooltip>

<!-- Less spacing from element -->
<wally-tooltip text="Close" [offset]="1">
  <button>Small offset</button>
</wally-tooltip>

[ Production Examples ]

Dashboard Toolbar

<!-- Toolbar with tooltips -->
<div class="flex gap-2">
  <wally-tooltip text="Export data to CSV">
    <wally-button variant="outline" ariaLabel="Export">
      <svg class="size-5"><!-- Export icon --></svg>
    </wally-button>
  </wally-tooltip>

  <wally-tooltip text="Refresh dashboard">
    <wally-button variant="outline" ariaLabel="Refresh">
      <svg class="size-5"><!-- Refresh icon --></svg>
    </wally-button>
  </wally-tooltip>

  <wally-tooltip text="Settings">
    <wally-button variant="outline" ariaLabel="Settings">
      <svg class="size-5"><!-- Settings icon --></svg>
    </wally-button>
  </wally-tooltip>
</div>

Form Field Help

<!-- Form field with help tooltip -->
<div class="flex items-start gap-2">
  <wally-input label="Email" type="email" placeholder="[email protected]" class="flex-1" />
  <wally-tooltip text="We'll never share your email">
    <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" class="size-4 text-neutral-500 cursor-help mt-[30px]">
      <path stroke-linecap="round" stroke-linejoin="round" d="m11.25 11.25.041-.02a.75.75 0 0 1 1.063.852l-.708 2.836a.75.75 0 0 0 1.063.853l.041-.021M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9-3.75h.008v.008H12V8.25Z" />
    </svg>
  </wally-tooltip>
</div>

[ Future Features ]

Rich Content Support (Coming Soon)

Future version will support custom HTML content projection, allowing images, formatted text, and interactive elements inside tooltips.

<!-- Future API (v2.0.0) -->
<wally-tooltip>
  <div class="p-4">
    <img src="preview.jpg" />
    <h4>Custom Content</h4>
    <p>Any HTML here</p>
  </div>

  <!-- Trigger element -->
  <button>Show Rich Tooltip</button>
</wally-tooltip>

[ API Reference ]

Input Properties

PropertyTypeDefaultDescription
textstringrequiredText content displayed in the tooltip
position'top' | 'bottom' | 'left' | 'right' | 'auto''auto'Tooltip position. 'auto' intelligently detects best position based on viewport space
delaynumber200Show delay in milliseconds
disabledbooleanfalseDisables tooltip display
offsetnumber2Distance from target element in pixels

Technical Features

FeatureDescription
Auto-PositioningDetects viewport space and positions tooltip automatically with priority: top → bottom → right → left
Overflow DetectionAutomatically shifts tooltip horizontally/vertically when near viewport edges (8px padding)
Smooth AnimationGPU-accelerated fade transitions (150ms show, 100ms hide)
Accessibilityrole="tooltip", aria-hidden, keyboard support (focus/blur events)
Dark ModeAutomatic theme detection and color adaptation