useOverlay
Provides all relevant `Overlay` behavior and provides a ref for the overlay's container.
useOverlay calls all of the relevant behavior Hooks that all Overlay components & composite components should have and returns a ref to be passed down to the overlay's container.
These behaviors include:
positionSettings and positionDeps.EscapeNote: useOverlay and Overlay do not manage the open state of the overlay. We leave control of the open state up to the user. All behaviors are built with the assumption that the overlay will not be rendered on the page & fully unmounted when it is not visible. See the examples for details on how to conditionally render a component in JSX.
| Name | Type | Required | Description |
|---|---|---|---|
| onEscapePress | function | required | Function to call when user presses the Escape key |
| onOutsideClick | function | required | Function to call when user clicks outside of the overlay |
| ignoreClickRefs | React.RefObject<HTMLElement> [] | optional | Refs to click clicks on in the onOutsideClick function, useful for ignoring clicks on elements that trigger the overlay visibility. |
| initialFocusRef | React.RefObject<HTMLElement> | optional | Ref to focus when overlay is mounted. |
| returnFocusRef | React.RefObject<HTMLElement> | required | Ref to focus when overlay is unmounted. Important for accessibility. |