1.0.1 • Published 24 days ago

@ngx-popovers/tooltip v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
24 days ago

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

InputDescriptionTypeDefault
placementPosition of the component according to the anchorPlacement'bottom'
templateCustom template for the tooltipTemplateRef<any>undefined
middlewareList of floating-ui middlewares without arrowMiddlewareListoffset(4), flip()
debounceTime delay before the component is displayednumber100
arrowAdds an arrow to the tooltipbooleanfalse
arrowPaddingPrevents overflow of the tooltip element corners if it has border-radiusnumber2
bindToRender the component into an elementstring \| HTMLElement'.body'
autoUpdateAutomatically updates the positionbooleanfalse
ngxValueState of the tooltip (open/close)booleanfalse

Output Parameters

OutputDescriptionType
ngxValueChangeEmitter for changes in ngxValueEventEmitter<boolean>
showEndEmitter for when the component is shownEventEmitter
hideEndEmitter for when the component is hiddenEventEmitter
computePositionEmitter for every call of computePositionEventEmitter<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:

1.0.1

24 days ago

1.0.0

1 month ago

0.1.5

3 months ago

0.1.4

3 months ago

0.1.3

3 months ago

0.1.2

3 months ago

0.1.1

3 months ago

0.1.0

3 months ago

0.0.23

3 months ago

0.0.22

4 months ago

0.0.21

4 months ago

0.0.20

4 months ago

0.0.19

4 months ago

0.0.18

4 months ago

0.0.17

4 months ago

0.0.15

4 months ago

0.0.16

4 months ago

0.0.14

4 months ago

0.0.13

4 months ago

0.0.10

4 months ago

0.0.11

4 months ago

0.0.12

4 months ago

0.0.9

4 months ago

0.0.8

4 months ago

0.0.7

5 months ago

0.0.6

5 months ago

0.0.5

5 months ago

0.0.4

5 months ago

0.0.3

5 months ago

0.0.2

5 months ago

0.0.1

5 months ago