useDismissable
Close a panel on an outside click or Escape.
useDismissable(open, insideRefs, onDismiss)Calls onDismiss when the user clicks outside the given elements or presses Escape, while open is true. It is what closes the dropdown panels in Select, Popover, the date pickers and ActionMenu. Pass every element that counts as "inside", for example the trigger wrapper and a portalled panel.
Last dismissed by: nothing yet
API
openbooleanListeners are attached only while this is true.
insideRefsRefObject | RefObject[]Clicks inside any of these elements do not dismiss.
onDismiss(reason: 'outside' | 'escape') => voidCalled with why it was dismissed.
| Prop | Type | Default | Description |
|---|---|---|---|
open | boolean | – | Listeners are attached only while this is true. |
insideRefs | RefObject | RefObject[] | – | Clicks inside any of these elements do not dismiss. |
onDismiss | (reason: 'outside' | 'escape') => void | – | Called with why it was dismissed. |
See also:SelectMultiSelectSearchSelectPopoverActionMenuDatePickerDateRangePickerTimePickerNotificationCenter