JSPM

@fluentui/react-positioning

0.0.0-nightly-20230802-0414.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 208322
  • Score
    100M100P100Q165062F
  • License MIT

A react wrapper around Popper.js for Fluent UI

Package Exports

  • @fluentui/react-positioning
  • @fluentui/react-positioning/package.json

Readme

@fluentui/react-positioning

A react hook wrapper around Popper.js for Fluent UI.

Usage

import React from 'react';
import { usePopper } from '@fluentui/react-positioning';

function PopupExample: React.FC = ({ children }) => {
  const {targetRef, containerRef} = usePopper();
  const [open, setOpen] = React.useState(false);

  const onClick = () => setOpen(s => !s);
  return (
    <>
      <button ref={targetRef} onClick={onClick}> Toggle popup </button>
      { open && <div ref={containerRef}>{children}</div> }
    </>
  )
}