SwiftUI.js
Components

ConfirmationDialog

ConfirmationDialog presents a stack of actions that asks the user to confirm an intent. It aligns with SwiftUI's `confirmationDialog` mental model while using web-native dialog semantics.

ConfirmationDialog presents a stack of actions that asks the user to confirm an intent. It aligns with SwiftUI's `confirmationDialog` mental model while using web-native dialog semantics.

Examples

Default

Preview unavailable for this example in the static docs build.

Show code
function DefaultDialog() {
  const [isVisible, setIsVisible] = useState(false)

  return (
    <>
      <Button onClick={() => setIsVisible(true)}>Show Confirmation Dialog</Button>
      <ConfirmationDialog
        title="Delete draft?"
        message="This action cannot be undone."
        isVisible={isVisible}
        onDismiss={() => setIsVisible(false)}
        actions={[
          { label: 'Delete', style: 'destructive', action: () => setIsVisible(false) },
          { label: 'Cancel', style: 'cancel', action: () => setIsVisible(false) },
        ]}
      />
    </>
  )
}

API

PropTypeRequiredDescription
titlestringNoOptional title shown above the actions.
messagestringNoOptional supporting message.
isVisiblebooleanYesWhether the dialog is currently visible.
onDismiss() => voidYesCalled when the dialog should close.
actionsIConfirmationDialogAction[]YesAvailable actions.

Inherits additional props from IBaseComponent.

Overview

ConfirmationDialog presents a stack of actions that asks the user to confirm an intent. It aligns with SwiftUI's confirmationDialog mental model while using web-native dialog semantics.

Notes

  • Use actions to declare the available choices.
  • cancel and destructive action styles mirror Apple's emphasis rules.
  • The dialog dismisses on action selection, backdrop click, or Escape.

On this page