GithubHelp home page GithubHelp logo

synonymouse / floating-ui Goto Github PK

View Code? Open in Web Editor NEW

This project forked from floating-ui/floating-ui

0.0 0.0 0.0 10.1 MB

๐Ÿฟ JavaScript positioning library for tooltips, popovers, dropdowns, and more

Home Page: https://floating-ui.com

License: MIT License

JavaScript 45.44% HTML 14.78% TypeScript 39.11% CSS 0.67%

floating-ui's Introduction

Floating UI

Popper is now Floating UI! For Popper v2, visit its dedicated branch.

Website

Floating UI is a low-level library for positioning "floating" elements like tooltips, popovers, dropdowns, menus and more. Since these types of elements float on top of the UI without disrupting the flow of content, challenges arise when positioning them.

Floating UI exposes primitives which enable a floating element to be positioned next to a given reference element while appearing in view for the user as best as possible. Features include overflow prevention (or collision awareness), placement flipping, and more.

  • Tiny: 600-byte core with highly modular architecture for tree-shaking
  • Low-level: Hyper-granular control over positioning behavior
  • Pure: Predictable, side-effect free behavior
  • Extensible: Powerful middleware system
  • Platform-agnostic: Runs on any JavaScript environment which provides measurement APIs, including the web and React Native

Installation

To use it on the web:

npm install @floating-ui/dom
yarn add @floating-ui/dom

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.

React

Components

Right now, Floating UI focuses on positioning floating elements, but a package that exposes higher-level primitives for building these elements more easily is in 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.

  • Clone the repo
  • Install dependencies in root directory with npm install
  • npm run dev in the root will launch the @floating-ui/dom development visual tests at http://localhost:1234/spec. You can fiddle around with each test file in packages/dom/test/visual/spec/. Reload the page to see your changes.

License

MIT

floating-ui's People

Contributors

alexfsmirnov avatar andarist avatar atlas-fox avatar atomiks avatar ayc0 avatar cuberoot avatar cuyl avatar dependabot[bot] avatar eps1lon avatar fezvrasta avatar hipstersmoothie avatar ianwalter avatar jacwright avatar joelkang avatar joshiste avatar jsg2021 avatar jspangler avatar ktmouk avatar lpoulter avatar lsroman avatar lyleunderwood avatar mcous avatar oliverjash avatar pascalduez avatar ptu14 avatar sandstrom avatar semeleven avatar tvanro avatar westbrook avatar wszydlak avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.