🌐 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="注销吗?"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>);}
🌐 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="删除账户?"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>);}