Socket
Socket
Sign inDemoInstall

@floating-ui/devtools

Package Overview
Dependencies
3
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @floating-ui/devtools

This is the platform-agnostic devtools package of Floating UI, exposing mechanisms to be used together with [Chrome devtools extension](https://chromewebstore.google.com/detail/floating-ui-devtools/ninlhpbnkjidaokbmgebblaehpokdmgb?hl=en) to help debugging


Version published
Weekly downloads
37K
decreased by-20.44%
Maintainers
2
Install size
29.0 kB
Created
Weekly downloads
 

Readme

Source

Floating UI Devtools

This is the platform-agnostic devtools package of Floating UI, exposing mechanisms to be used together with Chrome devtools extension to help debugging Floating UI

How to use

This package exposes a middleware to be added at the end of the middleware chain, which will inject the data to be consumed by the devtools extension.

⚠️ Do not forget to remove the middleware before shipping to production

Install

npm install @floating-ui/devtools

Usage

// example with @floating-ui/react
import {devtools} from '@floating-ui/devtools';

export const Default = () => {
  const [isOpen, setIsOpen] = useState(false);

  const {refs, floatingStyles, context} = useFloating({
    open: isOpen,
    onOpenChange: setIsOpen,
    // add the middleware to the end of the middleware chain if in dev mode
    middleware: [import.meta.env.DEV && devtools(document)],
  });

  const click = useClick(context);

  const {getReferenceProps, getFloatingProps} = useInteractions([click]);

  return (
    <>
      <button ref={refs.setReference} {...getReferenceProps()}>
        Reference element
      </button>
      {isOpen && (
        <div
          ref={refs.setFloating}
          style={floatingStyles}
          {...getFloatingProps()}
        >
          Floating element
        </div>
      )}
    </>
  );
};

Contribution

  • run pnpm --filter @floating-ui/devtools run build from root folder

FAQs

Last updated on 16 Jan 2024

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc