All Projects → floating-ui → floating-ui

floating-ui / floating-ui

Licence: MIT license
A low-level toolkit to create floating elements. Tooltips, popovers, dropdowns, and more

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects
HTML
75241 projects

Projects that are alternatives of or similar to floating-ui

Popper Core
🍿 JavaScript positioning library for tooltips, popovers, dropdowns, and more
Stars: ✭ 18,903 (-19.51%)
Mutual labels:  popover, position, tooltip, dropdown, popovers, positioning-engine, positioning, tooltip-position
Ng Bootstrap
Angular powered Bootstrap
Stars: ✭ 7,872 (-66.48%)
Mutual labels:  popover, tooltip, dropdown
React Laag
Hooks to build things like tooltips, dropdown menu's and popovers in React
Stars: ✭ 568 (-97.58%)
Mutual labels:  popover, tooltip, dropdown
React Layer Stack
Layering system for React. Useful for popover/modals/tooltip/dnd application
Stars: ✭ 152 (-99.35%)
Mutual labels:  popover, tooltip, dropdown
Tippyjs
Tooltip, popover, dropdown, and menu library
Stars: ✭ 9,433 (-59.83%)
Mutual labels:  popover, tooltip, dropdown
react-popover
Customizable positioning for tooltips, menus, and any other DOM elements inside of a container
Stars: ✭ 13 (-99.94%)
Mutual labels:  popover, tooltip, positioning
Tippyjs React
React component for Tippy.js (official)
Stars: ✭ 1,081 (-95.4%)
Mutual labels:  popover, tooltip, dropdown
React Cool Portal
😎 🍒 React hook for Portals, which renders modals, dropdowns, tooltips etc. to <body> or else.
Stars: ✭ 458 (-98.05%)
Mutual labels:  popover, tooltip, dropdown
react-layer-stack
Layering system for React. Useful for popover/modals/tooltip/dnd application
Stars: ✭ 158 (-99.33%)
Mutual labels:  popover, tooltip, dropdown
toppy
Overlay library for Angular 7+
Stars: ✭ 81 (-99.66%)
Mutual labels:  popover, tooltip, dropdown
Sveltejs Tippy
Tippy.js for Svelte
Stars: ✭ 26 (-99.89%)
Mutual labels:  popover, tooltip
Hibiscus.js
Native Angular directives for Bootstrap4
Stars: ✭ 115 (-99.51%)
Mutual labels:  popover, tooltip
React Popper Tooltip
A React hook to effortlessly build smart tooltips.
Stars: ✭ 149 (-99.37%)
Mutual labels:  popover, tooltip
Popover
Angular CDK Popover, no default style, examples using @angular/material
Stars: ✭ 156 (-99.34%)
Mutual labels:  popover, tooltip
React Popper
🍿⚛Official React library to use Popper, the positioning library
Stars: ✭ 2,173 (-90.75%)
Mutual labels:  popover, tooltip
Ember Tooltips
Easy and extendible tooltips for Ember components - http://sir-dunxalot.github.io/ember-tooltips/
Stars: ✭ 205 (-99.13%)
Mutual labels:  popover, tooltip
svelte-popper
🍿🔗Official Svelte wrapper for Popper - the positioning library
Stars: ✭ 27 (-99.89%)
Mutual labels:  popovers, positioning
Tooltip Sequence
A simple step by step tooltip helper for any site
Stars: ✭ 287 (-98.78%)
Mutual labels:  popover, tooltip
You Dont Need Javascript
CSS is powerful, you can do a lot of things without JS.
Stars: ✭ 16,514 (-29.68%)
Mutual labels:  popover, tooltip
react-popper
🍿⚛Official React library to use Popper, the positioning library
Stars: ✭ 2,415 (-89.72%)
Mutual labels:  popover, tooltip

Floating UI

Popper is now Floating UI! For Popper v2, visit its dedicated branch. For help on migrating, check out the Migration Guide.

Floating UI is a tiny, low-level library for creating "floating" elements like tooltips, popovers, dropdowns, menus, and more.

The library provides two key functionalities:

1. Anchored positioning primitives

Floating UI provides a JavaScript implementation of “anchored positioning” — the ability to anchor an element (like a tooltip) to another one (like a button) while simultaneously keeping it in view as best as possible with collision detection.

2. User interaction primitives

When creating a popover, dropdown menu, select, or combobox component that follows WAI-ARIA authoring practices, the complexity increases dramatically. Focus traps, indexed navigation, and typeahead are difficult to get right.

This functionality is currently available for React DOM.

Install

Choose the package that suits you.

Vanilla DOM positioning

Use with vanilla JavaScript or a non-React framework (view tutorial).

npm install @floating-ui/dom

React DOM positioning

Use with React DOM (view docs).

npm install @floating-ui/react-dom

React DOM interactions and positioning

Craft interactions in addition to anchored positioning (view docs).

npm install @floating-ui/react-dom-interactions

React Native positioning

Use with React Native (view docs).

npm install @floating-ui/react-native

Canvas or other platforms

Learn about creating a Platform.

npm install @floating-ui/core

Quick start

import {computePosition} from '@floating-ui/dom';

const referenceElement = document.querySelector('#button');
const floatingElement = document.querySelector('#tooltip');

function applyStyles({x = 0, y = 0, strategy = 'absolute'}) {
  Object.assign(floatingElement.style, {
    position: strategy,
    left: `${x}px`,
    top: `${y}px`,
  });
}

applyStyles();

computePosition(referenceElement, floatingElement, {
  placement: 'right',
}).then(applyStyles);

Visit the docs for detailed information.

Package entry points

Using webpack, Vite, or Parcel? Skip this section as modern bundlers handle this for you.

Floating UI uses process.env.NODE_ENV to determine whether your build is in development or production mode. This allows us to add console warnings and errors during development to help you but ensure they get stripped out in production to keep the bundle size small.

This causes an error in Rollup and low/no-build setups. To solve this, Floating UI exports browser-ready ES modules. Leverage the "browser" package export condition to use these modules.

Rollup example

The browser option in the nodeResolve() plugin will select browser versions of packages if available.

import {nodeResolve} from '@rollup/plugin-node-resolve';

export default {
  // ...
  plugins: [
    nodeResolve({
      browser: true,

      // Add this line for development config, omit for
      // production config
      exportConditions: ['development'],
    }),
  ],
};

Contributing

This project is a monorepo written in TypeScript using npm workspaces. The website is using Next.js SSG and Tailwind CSS for styling.

  • Fork and clone the repo
  • Install dependencies in root directory with npm install
  • Build initial package dist files with npm run build

Testing grounds

npm -w packages/dom run dev in the root will launch the @floating-ui/dom development visual tests at http://localhost:1234. The playground uses React to write each test route, bundled by Parcel.

Each route has screenshots taken of the page by Playwright to ensure all the functionalities work as expected; this is an easy, reliable and high-level way of testing the code.

Below the main container are UI controls to turn on certain state and options. Every single combination of state is tested visually via the snapshots to cover as much as possible.

Credits

The floating shapes in the banner image are made by the amazing artists @artstar3d, @killnicole and @liiiiiiii on Figma — check out their work!

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].