atomiks / tippyjs

Tooltip, popover, dropdown, and menu library
https://atomiks.github.io/tippyjs/
MIT License
11.86k stars 520 forks source link

Option to display tooltip center-center (over the element itself) #1097

Closed microHoffman closed 1 year ago

microHoffman commented 1 year ago

Hello, is there an option to display tooltip over the element (something like center-center)?

atomiks commented 1 year ago
tippy('button', {
  content: 'tooltip',
  arrow: false,
  popperOptions: {
    modifiers: [
      {
        name: "offset",
        options: {
          offset: ({ reference, popper }) => [
            0,
            -reference.height / 2 - popper.height / 2,
          ],
        },
      },
    ],
  },
});

https://popper.js.org/docs/v2/modifiers/offset/#offset-1