Skip to content

Floating UI

A small JavaScript library for positioning tooltips, popovers and dropdowns next to other elements.

Stars
32.8k
Forks
1.7k
Licence
MIT
Language
TypeScript
Last update
10 days ago
Type
Library

What it is

Floating UI is a small JavaScript library for placing 'floating' elements such as tooltips, popovers, and dropdowns next to another element on a page. It keeps these elements attached to their anchor and adjusts their position so they stay visible when they would otherwise run off the edge of the viewport. For React users it also offers hooks and components for building accessible interactions.

  • Anchor a tooltip to a button and keep it inside the viewport when the button is near an edge
  • Build a dropdown menu that repositions itself while the user scrolls a container
  • Create accessible popover components in React using the interaction hooks
  • Position floating elements in a custom Vue or React Native app using the matching package

Great for

  • Web developers building tooltips, popovers, or dropdown menus
  • Teams that need positioning to work inside scrolling containers
  • React developers who want both positioning and interaction hooks
  • Developers who need a positioning engine for non-DOM platforms such as Canvas or WebGL

Not ideal for

  • People who only need a simple static CSS tooltip with no JavaScript, since this library adds a dependency for behavior plain CSS can cover
  • Non-developers, because the library is used through code and the README assumes familiarity with npm and JavaScript frameworks
Step-by-step guide: how to use Floating UIInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Node.js and npm

    Install for vanilla DOM

    npm install @floating-ui/dom

    Install for React DOM with positioning and interactions

    npm install @floating-ui/react

    Install for Vue

    npm install @floating-ui/vue
  2. 2

    Run it

    • Install the package for your platform using npm
    • Read the tutorial at floating-ui.com/docs/tutorial, which builds a basic tooltip
    • Use the computePosition API from the documentation to place your element
  3. 3

    Get the most out of it

    • Use the React package for interaction hooks if you need accessible popover behavior, not only positioning
    • Use the React DOM positioning-only package if you want a smaller bundle
    • Create a custom Platform to support Canvas, WebGL, or other JavaScript runtimes
    • Run the local visual test playgrounds with pnpm to see how each state combination behaves

Downloads

Strengths

  • Handles collisions with the viewport so floating elements stay visible, as described in the README
  • Supports several frameworks and platforms, including vanilla DOM, React, React Native, Vue, and a core package for custom platforms
  • Has a visual test setup with Playwright screenshots, which the README describes as covering every state combination

Trade-offs

  • Requires you to wire up the positioning yourself in code, so it is not a plug-and-play component set
  • Feature details beyond the README overview, such as the full API, are only available in the external documentation site
  • Popper v2 users need to follow a separate branch and migration guide

How it compares

ProjectStarsTypeLevelUpdatedBest for
floating-ui (this)32.8kLibraryintermediate10 days agoWeb developers building tooltips, popovers, or dropdown menus
tippyjs12.2kLibraryintermediate2.4 years agoWeb developers who want ready-made tooltips or dropdown menus without building them from scratch
Semantic-UI51kLibrarybeginner1.9 years agoFront-end developers who want prebuilt UI components they can restyle with themes
driver.js27kLibraryintermediate8 days agoWeb developers adding a product tour or onboarding flow to an existing web app
downshift12.3kLibraryintermediate4 months agoReact developers building a custom autocomplete or search-as-you-type input

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.