npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ngx-popovers/tooltip

v1.0.1

Published

The Tooltip component based on Angular 17+ and Floating-ui shows tooltips next to the trigger element

Downloads

85

Readme

Tooltip

This library was generated with Nx using floating-ui for Angular apps.

The Tooltip component displays tooltips next to the trigger element.

Check out the Demo

Usage

To use this library, add ngxTooltip to the HTML element.

<button
  ngxTooltip="Tooltip message"
  placement="top-end"
>
  Hover me!
</button>

Arrow

You can show the tooltip with an arrow:

<button
  ngxTooltip="Tooltip message"
  placement="top-end"
  arrow
  arrowPadding="8"
>
  Hover me!
</button>

API

Input Parameters

| Input | Description | Type | Default | |----------------|--------------------------------------------------------------------------|-------------------------|---------------------| | placement | Position of the component according to the anchor | Placement | 'bottom' | | template | Custom template for the tooltip | TemplateRef<any> | undefined | | middleware | List of floating-ui middlewares without arrow | MiddlewareList | offset(4), flip() | | debounce | Time delay before the component is displayed | number | 100 | | arrow | Adds an arrow to the tooltip | boolean | false | | arrowPadding | Prevents overflow of the tooltip element corners if it has border-radius | number | 2 | | bindTo | Render the component into an element | string \| HTMLElement | '.body' | | autoUpdate | Automatically updates the position | boolean | false | | ngxValue | State of the tooltip (open/close) | boolean | false |

Output Parameters

| Output | Description | Type | |-------------------|---------------------------------------------|---------------------------------| | ngxValueChange | Emitter for changes in ngxValue | EventEmitter<boolean> | | showEnd | Emitter for when the component is shown | EventEmitter | | hideEnd | Emitter for when the component is hidden | EventEmitter | | computePosition | Emitter for every call of computePosition | EventEmitter<ComputePosition> |

Configuration

Use the NGX_TOOLTIP_CONFIG token to change default properties with the NgxTooltipConfig class.

import { Provider } from '@angular/core';
import { NGX_TOOLTIP_CONFIG, NgxTooltipConfig } from '@ngx-popovers/tooltip';
/**
 * You have to install @ngx-popovers/core to import middleware.
 * Version of @ngx-popovers/core is the same as @ngx-popovers/tooltip
 */
import { flip, offset, shift } from '@ngx-popovers/core';

export const TooltipConfigProvider: Provider = {
  provide: NGX_TOOLTIP_CONFIG,
  useValue: new NgxTooltipConfig({
    debounce: 50,
    placement: 'top-end',
    /* Middleware list from floating-ui */
    middleware: [
      flip(),
      shift(),
      offset(8)
    ]
  })
};

Custom View

You can use your own component to visualize tooltips.

There is an injection token NGX_TOOLTIP_COMPONENT that replaces the default component.

Example:

@Component({
  standalone: true,
  styles: `
    .my-tooltip {
      padding: 5px;
      display: flex;
      flex-direction: column;
      gap: 4px;
      background: #fff;
      border: 1px solid #dedede;
    }
  `,
  template: `
    <div class="my-tooltip">
      <span>I Custom Tooltip!</span>
      <span>text: {{ text }}</span>
    </div>
  `
})
export class CustomTooltip extends TooltipBase {
}

export const TooltipProvider: Provider = {
  provide: NGX_TOOLTIP_COMPONENT,
  useValue: CustomTooltip
};

Arrow Component

Refer to the core package.

Sources

Other npm packages from this library: