This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
ConfirmationDialog
A SwiftUI ConfirmationDialog component for presenting confirmation prompts.
iOS
tvOS
Included in Expo Go
Recommended version:
~56.0.26
Expo UI ConfirmationDialog matches the official SwiftUI confirmationDialog API and presents an action sheet-style dialog with a title, actions, and an optional message.
Use ConfirmationDialog.Trigger to define the visible element and ConfirmationDialog.Actions to provide the dialog buttons.
BasicConfirmationDialogExample.tsx
import{ useState }from'react';import{Host,ConfirmationDialog,Button,Text}from'@expo/ui/swift-ui';exportdefaultfunctionBasicConfirmationDialogExample(){const[isPresented, setIsPresented]=useState(false);return(<HostmatchContents><ConfirmationDialogtitle="Are you sure?"isPresented={isPresented}onIsPresentedChange={setIsPresented}titleVisibility="visible"><ConfirmationDialog.Trigger><Buttonlabel="Show Dialog"onPress={()=>setIsPresented(true)}/></ConfirmationDialog.Trigger><ConfirmationDialog.Actions><Buttonlabel="Confirm"onPress={()=>setIsPresented(false)}/><Buttonlabel="Cancel"role="cancel"/></ConfirmationDialog.Actions></ConfirmationDialog></Host>);}
Destructive action confirmation
Use role="destructive" on a Button inside ConfirmationDialog.Actions to style it as a destructive action.
DestructiveConfirmationDialogExample.tsx
import{ useState }from'react';import{Host,ConfirmationDialog,Button,Text}from'@expo/ui/swift-ui';exportdefaultfunctionDestructiveConfirmationDialogExample(){const[isPresented, setIsPresented]=useState(false);return(<HostmatchContents><ConfirmationDialogtitle="Delete Item?"isPresented={isPresented}onIsPresentedChange={setIsPresented}titleVisibility="visible"><ConfirmationDialog.Trigger><Buttonlabel="Delete"role="destructive"onPress={()=>setIsPresented(true)}/></ConfirmationDialog.Trigger><ConfirmationDialog.Actions><Buttonlabel="Delete"role="destructive"onPress={()=>{console.log('Deleted');setIsPresented(false);}}/><Buttonlabel="Cancel"role="cancel"/></ConfirmationDialog.Actions><ConfirmationDialog.Message><Text>This action cannot be undone.</Text></ConfirmationDialog.Message></ConfirmationDialog></Host>);}
With message and multiple actions
Use ConfirmationDialog.Message to display a descriptive message below the title, and include multiple action buttons for different choices.
MultiActionConfirmationDialogExample.tsx
import{ useState }from'react';import{Host,ConfirmationDialog,Button,Text}from'@expo/ui/swift-ui';exportdefaultfunctionMultiActionConfirmationDialogExample(){const[isPresented, setIsPresented]=useState(false);return(<HostmatchContents><ConfirmationDialogtitle="Save Changes?"isPresented={isPresented}onIsPresentedChange={setIsPresented}titleVisibility="visible"><ConfirmationDialog.Trigger><Buttonlabel="Close Document"onPress={()=>setIsPresented(true)}/></ConfirmationDialog.Trigger><ConfirmationDialog.Actions><Buttonlabel="Save"onPress={()=>console.log('Saved')}/><Buttonlabel="Discard"role="destructive"onPress={()=>console.log('Discarded')}/><Buttonlabel="Cancel"role="cancel"/></ConfirmationDialog.Actions><ConfirmationDialog.Message><Text>You have unsaved changes. What would you like to do?</Text></ConfirmationDialog.Message></ConfirmationDialog></Host>);}
Hidden title
Set titleVisibility="hidden" to hide the dialog title while still showing the actions and message. You should still provide a title for accessibility.
HiddenTitleConfirmationDialogExample.tsx
import{ useState }from'react';import{Host,ConfirmationDialog,Button,Text}from'@expo/ui/swift-ui';exportdefaultfunctionHiddenTitleConfirmationDialogExample(){const[isPresented, setIsPresented]=useState(false);return(<HostmatchContents><ConfirmationDialogtitle="Hidden Title"isPresented={isPresented}onIsPresentedChange={setIsPresented}titleVisibility="hidden"><ConfirmationDialog.Trigger><Buttonlabel="Show Dialog"onPress={()=>setIsPresented(true)}/></ConfirmationDialog.Trigger><ConfirmationDialog.Actions><Buttonlabel="OK"onPress={()=>setIsPresented(false)}/><Buttonlabel="Cancel"role="cancel"/></ConfirmationDialog.Actions><ConfirmationDialog.Message><Text>Only the message and actions are visible.</Text></ConfirmationDialog.Message></ConfirmationDialog></Host>);}