useGlobalOverlay

Global overlay hook for managing modals and dialogs in a React Native app.

The useGlobalOverlay hook provides a convenient way to manage modals and dialogs from anywhere in your React Native app. It requires your app to be wrapped with the SmacOverlayProvider.

⚠️ Important: You must wrap your app with SmacOverlayProvider to use useGlobalOverlay. More: Installation.

Props

The useGlobalOverlay hook provides functions to control global modal dialogs.

Props

NameTypeDescription
showAlertDialog(options: AlertDialogOptions) => voidDisplays a basic dialog with title, description, and action buttons.
showDialog(options: DialogOptions) => voidSimilar to showAlertDialog, but allows custom content in the dialog body.
showCustomDialog(options: CustomDialogOptions) => voidDisplays a fully custom dialog. Caller is responsible for providing content.
showToast(options: ToastOptions) => voidDisplays a toast. Caller is responsible for providing content.
hideModal() => voidManually hides the currently visible dialog.

AlertDialogOptions

NameTypeRequiredDescription
titlestringNoTitle displayed in the dialog header.
descriptionstringNoDescription text displayed under the title.
cancelActionstringNoLabel for the cancel/close button. Defaults to "Close".
continueActionstringNoLabel for the continue/confirm button. Defaults to "Continue".
onClose() => voidNoCalled when the cancel button is pressed or modal is dismissed.
onContinue() => voidNoCalled when the continue button is pressed.
onModalClosed() => voidNoCallback fired after the modal has been closed (via backdrop or buttons).

DialogOptions

Extends AlertDialogOptions with additional custom content.

NameTypeRequiredDescription
content(close: () => void) => React.ReactNodeYesCustom content inserted in the middle of the dialog. Receives a close() function.
titlestringNoTitle displayed in the dialog header.
descriptionstringNoDescription text displayed under the title.
cancelActionstringNoLabel for the cancel/close button. Defaults to "Close".
continueActionstringNoLabel for the continue/confirm button. Defaults to "Continue".
onClose() => voidNoCalled when the cancel button is pressed or modal is dismissed.
onContinue() => voidNoCalled when the continue button is pressed.
onModalClosed() => voidNoCallback fired after the modal has been closed (via backdrop or buttons).

CustomDialogOptions

NameTypeRequiredDescription
content(close: () => void) => React.ReactNodeYesFully custom content for the entire dialog. Receives a close() callback.
onModalClosed() => voidNoCalled after the modal has been closed (via backdrop or user action).

ToastOptions

NameTypeRequiredDescription
titlestringNoTitle text displayed at the top of the toast.
descriptionstringNoOptional description text displayed below the title.
variantVariantsNoStyle variant of the toast (e.g., "primary", "destructive").
leftIconIconNameNoThe icon prop must be one of icons
durationnumberNoDuration in milliseconds before the toast auto-dismisses. Default is 3s.
undoAction(close: () => void) => {}NoOptional undo callback that receives a close() function for dismissing.