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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@advdominion/tooltip

v5.0.0

Published

- [Floating UI](https://floating-ui.com) версии ^1.0.0

Downloads

47

Readme

tooltip

Требования

Подключение и настройка

HTML

<button type="button">Кнопка</button>

JS

Минимальные настройки

import { createTooltip } from '@advdominion/tooltip';

createTooltip(document.querySelector('button'), 'Подсказка');

Все настройки со значениями по умолчанию

import { createTooltip } from '@advdominion/tooltip';

createTooltip(document.querySelector('button'), 'Подсказка', {
    animation: [
        [{ opacity: 0 }, { opacity: 1 }],
        [{ opacity: 1 }, { opacity: 0 }],
    ],
    appendTo: document.body,
    arrow: true,
    delay: [0, 0],
    duration: [0, 0],
    easing: ['linear', 'linear'],
    hideOnClick: true,
    interactive: true,
    offset: [0, 8],
    placement: 'top',
    shiftPadding: [8, 0],
    theme: 'light',
    trigger: 'mouseenter',
    virtualReference: undefined,
    zIndex: '',
    // Callback-функции, по умолчанию не заданы
    onCreate(instance) {},
    onMount(instance) {},
    onShow(instance) {},
    onShown(instance) {},
    onHide(instance) {},
    onHidden(instance) {},
});

hideOnClick

  • true (по умолчанию) — всплывающая подсказка скрывается при клике по любому элементу на странице (кроме самой всплывающей подсказки).
  • 'all' — всплывающая подсказка скрывается при клике по любому элементу на странице (включая саму всплывающую подсказку).
  • 'toggle' — всплывающая подсказка скрывается только при клике по элементу, который её вызывает.
virtualReference

Настройка используется для кастомного позиционирования, ожидает объект с методом getBoundingClientRect.

Например, позиционирование всплывающей подсказки относительно виртуального элемента размером 100×50, который располагается в левой верхней точке экрана:

createTooltip(document.querySelector('button'), 'Подсказка', {
    virtualReference: {
        getBoundingClientRect() {
            return {
                x: 0,
                y: 0,
                top: 0,
                left: 0,
                bottom: 50,
                right: 100,
                width: 100,
                height: 50,
            };
        },
    },
});

Свойства

$tooltip

DOM-элемент всплывающей подсказки (имеет свойство _reference для доступа к элементу, на котором был вызван createTooltip)

options

Текущие настройки

isVisible

Видимость всплывающей подсказки - true/false

Методы

show
document.querySelector('button')._tooltip.show();
hide
document.querySelector('button')._tooltip.hide();
setContent
document.querySelector('button')._tooltip.setContent('Новая подсказка');
updateOptions
document.querySelector('button')._tooltip.updateOptions({ placement: 'bottom' });

Настройки так же можно переназначать, используя data-атрибуты:

<button type="button" data-tooltip-placement="bottom">Кнопка</button>
destroy
document.querySelector('button')._tooltip.destroy();

Стили

$b: '.tooltip';

#{$b} {
    left: 0;
    max-width: calc(100vw - 32px);
    position: absolute;
    top: 0;
    width: max-content;
    z-index: 200;

    @media (min-width: 900px) {
        max-width: 300px;
    }

    &__root {
    }

    &__arrow {
        #{$b}_theme_light & {
            background-color: white;
            height: 8px;
            width: 8px;
        }
    }

    &__container {
        #{$b}_theme_light & {
            background-color: white;
            box-shadow: 0 0 8px 0 rgba(0, 0, 0, 0.2);
        }
    }
}