New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

floating-tooltip-react

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

floating-tooltip-react

Headless popper primitive for React built on @floating-ui/react.

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

floating-tooltip-react

Headless, ergonomic popper primitive for React (tooltips, popovers, menus) built on top of @floating-ui/react.

It delivers Floating UI's two core capabilities, positioning and interaction, via a simple, easy-to-use API that you can drop into any design system.

Demo

Try it live: https://kutneruri.github.io/floating-popper/

Screenshot

Features

  • Implemented behaviors: Hover, click, click-away, Escape key, etc.
  • Fully controlled with a simple open={boolean} and a onOpen(boolean) callback
  • Enterable hover with polygon-safe close and configurable hoverDelay
  • Enter/exit animations; optional portal support
  • Fully customizable - no CSS or design assumptions
  • Built in arrow support.

Installation

npm install floating-tooltip-react @floating-ui/react

Quick Start

As simple as passing children and a pop prop. Add triggers as necessary.

import React from "react";
import BasePopper from "floating-tooltip-react";

function App() {
  return (
    <BasePopper triggerOnHover pop="Hello, World!">
      <span>Hover over me</span>
    </BasePopper>
  );
}

DOM structure

For ref handling, the popper renders its own div. Beyond that, it's as minimal as possible.

<BasePopper
  className="my-popper"
  popClass="my-pop"
  pop={<div className="pop-component">Pop content</div>}
>
  <button type="button" className="reference">
    Reference element
  </button>
</BasePopper>

{/* -- becomes --> */}

<div class="my-popper">
  <button type="button" class="reference">
    Reference element
  </button>

  <div
    /* positioned container (Floating UI styles applied inline) */
    style="position: absolute; top: 100px; left: 200px; transform: translate3d(0px, 6px, 0px);"
  >
    <div class="my-pop" /* your pop wrapper via slots.Pop */>
      <div class="pop-component">Pop content</div> {/* your pop node */}

      {/* if withArrow is true: */}
      <svg>...</div>
    </div>
  </div>
</div>

API Reference

Rendering

PropTypeDefaultDescription
popElementFloating content to render. Required.
popPropsdiv propsProps for the pop element (e.g., className, role).
popContainerPropsdiv propsProps for the positioned container. Inline styles from Floating UI are merged with style.
slots.PopComponent"div"Override the default pop wrapper element.
slots.ArrowComponentFloatingArrowOverride the arrow renderer. Receives FloatingArrowProps except ref.

State & Control

PropTypeDefaultDescription
openbooleanfalseExplicit open state. When set, component is controlled.
onOpen(open: boolean) => voidCalled when internal triggers request an open state change.
disablebooleanfalseDisable all triggers.

Triggers

PropTypeDefaultDescription
triggerOnHoverbooleanfalseOpen/close on hover; disables click triggers by default.
enterablebooleantrueKeep open while hovering the popper; uses polygon-safe close.
hoverDelaynumber300Delay before changing open on hover (ms).
referenceEscbooleanfalseClose when clicking the reference while open. (when click is disabled)
triggerOnClickboolean!triggerOnHoverToggle on reference click.
triggerOnClickAwayboolean!triggerOnHoverClose on outside click.
triggerOnPopperbooleanfalseClose when clicking the popper itself.
triggerOnEscboolean!triggerOnHoverClose on Escape.

Positioning & Transitions

PropTypeDefaultDescription
placementPlacementDesired placement (e.g., "top", "bottom-start").
offsetnumber6Gap between reference and popper.
viewportPaddingPadding4Minimal distance from viewport edges.
autoPlacement'flip' or false"flip"Automatic placement strategy.
autoUpdatebooleanfalseContinuously update position (useful with portals or moving targets).
usePortalboolean or stringfalseRender in a Floating UI portal; pass an id string to target a specific node.
transitionMsnumber210Enter/exit duration in ms.
transitionStylesUseTransitionStylesPropsOverride useTransitionStyles configuration.

Arrow

PropTypeDefaultDescription
withArrowbooleanfalseRenders a pointing arrow connected to the popper.
arrowPadding`numberPadding`undefined
arrowClassstringundefinedConvenience class applied to the Arrow component.
arrowPropsPartial<FloatingArrowProps>undefinedAdditional props forwarded to the Arrow (e.g., width, height, tipRadius, stroke).

Events

PropTypeDescription
onPopperClick(event: React.MouseEvent) => voidFired when the pop surface is clicked.
onClickOutside(event: Event or undefined) => voidFired on outside click (if that trigger is enabled).
onReferenceEsc(event: Event or undefined) => voidFired when closing by clicking the reference (while open).

Usage Notes

  • The arrow is opt-in: set withArrow to true. Styling is left to you; see the demo for an example.
  • To fully customize the arrow, pass a custom slots.Arrow component. The default uses @floating-ui/react’s FloatingArrow.
  • If your popper uses a non-solid background or a shadow, style the arrow to visually match. The default library does not impose any CSS.

Contributing

Issues and PRs are welcome!

FAQs

Package last updated on 02 Nov 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts