18.2.0 • Published 10 months ago

@ngx-popovers/tooltip v18.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months 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>
strategyThis is the type of CSS position property to useabsolute | fixed | undefinedundefined

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:

18.2.0

10 months ago

18.1.2

10 months ago

18.1.1

10 months ago

18.1.0

11 months ago

18.0.1

1 year ago

18.0.0

1 year ago

17.0.0

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.23

1 year ago

0.0.22

1 year ago

0.0.21

2 years ago

0.0.20

2 years ago

0.0.19

2 years ago

0.0.18

2 years ago

0.0.17

2 years ago

0.0.15

2 years ago

0.0.16

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.10

2 years ago

0.0.11

2 years ago

0.0.12

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago