useFloatingWindow

Build a floating window that the user drags by a handle and that stays inside the viewport.

This is custom React hooks, you need to follow the Basic Rules when you use it.

General

Drag the window by its title, it stays inside the viewport.

APIs

useFloatingWindow

const useFloatingWindow = <
  T extends HTMLElement = HTMLElement,
  H extends HTMLElement = HTMLElement,
>(options?: { initialPosition?: { x: number; y: number } }) => {
  ref: RefObject<T | null>
  handleRef: RefObject<H | null>
  style: CSSProperties
  dragging: boolean
}
Edit this page on GitHub