gluestack-ui logo
Get Updates
Prompt to React Native UI
Home
Components
Hooks
Apps
MCP Server
Guides
Home
Overview
IntroductionQuick Start
Getting Started
InstallationTooling SetupVS Code ExtensionsFigma UI KitCLIgluestack-ui-nativewind-utils
Core Concepts
AccessibilityUniversal
Performance
Benchmarks
Theme Configuration
Default TokensCustomizing ThemeDark Mode
Components
All Components
Typography
HeadingrscTextrsc
Layout
BoxrscCenterrscDividerHStackrscVStackrscGridalpha, rsc
Feedback
AlertProgressSpinnerToast
Data Display
BadgeCardrscTablealpha
Forms
ButtonCheckboxFormControlInputLinkPressableRadioSelectSliderSwitchTextarea
Overlay
AlertDialogDrawerMenuModalPopoverPortalTooltip
Disclosure
ActionsheetAccordionBottomSheetalpha
Media And Icons
AvatarImageIconrsc
Others
FabSkeletonalpha, rsc
Hooks
useBreakPointValue
useMediaQuery
Apps
Dashboard App
Kitchensink App
Todo App
Starter Kit
MCP Server
MCP Server
Guides
Recipes
LinearGradient
Tutorials
Building Ecommerce App
More
Upgrade to v2Upgrade to v3FAQsReleasesRoadmapTroubleshootingDiscord FAQs

AlertDialog

Build seamless React Native dialogs with the AlertDialog component. Enhance user engagement with smooth and responsive modal prompts. This is an illustration of AlertDialog component.
size

Installation

Run the following command:

npx gluestack-ui add alert-dialog

API Reference

To use this component in your project, include the following import statement in your file.
import {
  AlertDialog,
  AlertDialogBackdrop,
  AlertDialogContent,
  AlertDialogHeader,
  AlertDialogCloseButton,
  AlertDialogFooter,
  AlertDialogBody,
} from '@/components/ui/alert-dialog';
export default () => (
  export default () => (
  <AlertDialog>
    <AlertDialogBackdrop />
    <AlertDialogContent>
      <AlertDialogHeader>
        <AlertDialogCloseButton />
      </AlertDialogHeader>
      <AlertDialogBody />
      <AlertDialogFooter />
    </AlertDialogContent>
  </AlertDialog>
);
);

Component Props

This section provides a comprehensive reference list for the component props, detailing descriptions, properties, types, and default behavior for easy project integration.

AlertDialog

Contains all alert dialog related layout style props and actions. It inherits all the properties of React Native's View component.
PropTypeDefaultDescription
isOpen
booleanfalseIf true, the alert-dialog will open. Useful for controllable state behavior.
onClose
() => any-Callback invoked when the alert-dialog is closed.
useRNModal
booleanfalseIf true, renders react-native native modal. (Only works in react-native)
defaultIsOpen
booleanfalseSpecifies the default open state of the AlertDialog
initialFocusRef
React.RefObject<any>-The ref of element to receive focus when the alert-dialog opens.
finalFocusRef
React.RefObject<any>-The ref of element to receive focus when the alert-dialog closes.
avoidKeyboard
boolean-If true, the AlertDialog will avoid the keyboard.
closeOnOverlayClick
booleantrueIf true, the AlertDialog will close when the overlay is clicked.
isKeyboardDismissable
booleantrueIf true, the keyboard can dismiss the AlertDialog

AlertDialogBackdrop

It is React Native's Pressable component, created using @legendapp/motion's
createMotionAnimatedComponent
function to add animation to the component. You can use any declarative animation library you prefer.

AlertDialogContent

It is @legendapp/motion's Motion.View component. You can use any declarative animation library you prefer.

AlertDialogCloseButton

It inherits all the properties of React Native's Pressable component.

AlertDialogHeader

It inherits all the properties of React Native's View component.

AlertDialogBody

It inherits all the properties of React Native's View component.

AlertDialogFooter

It inherits all the properties of React Native's View component

Features

  • Keyboard support for actions.

Accessibility

We have outlined the various features that ensure the AlertDialog component is accessible to all users, including those with disabilities. These features help ensure that your application is inclusive and meets accessibility standards.It uses React Native ARIA @react-native-aria/focus which follows the WAI-ARIA Alert and Message Dialogs Pattern.

Keyboard

  • Tab
    :
    • Moves focus to the next tabbable element inside the dialog.
    • If focus is on the last tabbable element inside the dialog, moves focus to the first tabbable element inside the dialog.
  • Shift + Tab
    :
    • Moves focus to the previous tabbable element inside the dialog.
    • If focus is on the first tabbable element inside the dialog, moves focus to the last tabbable element inside the dialog.
  • Escape
    : Closes the dialog.

Screen Reader

  • VoiceOver: When the button is focused, the screen reader will announce the button's label and provide instructions on how to click it. When the alert dialog is triggered, the screen reader will read its content.

States

  • When the alert dialog is triggered,
    aria-modal="true"
    is added to the alert dialog content. This attribute informs assistive technologies that the windows underneath the current alert dialog are not available for interaction(inert).

Props

AlertDialog component is created using View component from react-native. It extends all the props supported by React Native View, and the props mentioned below.

AlertDialog

NameValueDefault
size
xs | sm | md | lg | fullmd

Examples

The Examples section provides visual representations of the different variants of the component, allowing you to quickly and easily determine which one best fits your needs. Simply copy the code and integrate it into your project.

AlertDialog with Image

AlertDialog with icon + cta

AlertDialog with Delete Option

Edit this page on GitHub
Go backTextarea
Up nextDrawer
Go backTextarea
Up nextDrawer