This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
This is documentation for the next SDK version. For up-to-date documentation, see the latest version (SDK 57).
Alert
A SwiftUI Alert component for presenting native iOS alert dialogs.
iOS
tvOS
Included in Expo Go
Expo UI Alert matches the official SwiftUI alert API and presents a native iOS alert dialog with a title, actions, and an optional message.
Alert is the centered modal counterpart to ConfirmationDialog, which renders as an action sheet from the bottom of the screen. Both share the same trigger/actions/message slot model so callers can swap between them by changing the component name.
Combine role="cancel" with a confirm button to build a standard yes/no alert.
CancelConfirmAlertExample.tsx
import{ useState }from'react';import{Host,Alert,Button,Text}from'@expo/ui/swift-ui';exportdefaultfunctionCancelConfirmAlertExample(){const[isPresented, setIsPresented]=useState(false);return(<Hoststyle={{ flex:1}}><Alerttitle="Sign out?"isPresented={isPresented}onIsPresentedChange={setIsPresented}><Alert.Trigger><Buttonlabel="Sign out"onPress={()=>setIsPresented(true)}/></Alert.Trigger><Alert.Actions><Buttonlabel="Sign out"onPress={()=>console.log('Signed out')}/><Buttonlabel="Cancel"role="cancel"/></Alert.Actions><Alert.Message><Text>
You will need to sign in again to access your account.
</Text></Alert.Message></Alert></Host>);}
Destructive action
Use role="destructive" on a Button inside Alert.Actions to style it as a destructive action.
DestructiveAlertExample.tsx
import{ useState }from'react';import{Host,Alert,Button,Text}from'@expo/ui/swift-ui';exportdefaultfunctionDestructiveAlertExample(){const[isPresented, setIsPresented]=useState(false);return(<Hoststyle={{ flex:1}}><Alerttitle="Delete account?"isPresented={isPresented}onIsPresentedChange={setIsPresented}><Alert.Trigger><Buttonlabel="Delete account"role="destructive"onPress={()=>setIsPresented(true)}/></Alert.Trigger><Alert.Actions><Buttonlabel="Delete"role="destructive"onPress={()=>{console.log('Deleted');setIsPresented(false);}}/><Buttonlabel="Cancel"role="cancel"/></Alert.Actions><Alert.Message><Text>
This permanently deletes your account and all data. This
cannot be undone.
</Text></Alert.Message></Alert></Host>);}