Skip to content

Confirmation dialog - iOS ​

A confirmation dialog presents a set of choices in response to a user-initiated action, using the native iOS action sheet mechanism.

iOSreleased

iOS ​

Syntax ​

Apply the .warpConfirmationDialog() modifier to any view. The dialog is presented when isPresented becomes true.

swift
someView
    .warpConfirmationDialog(
        title: String,
        message: String? = nil,
        actions: [Warp.ConfirmationDialog.Action],
        isPresented: Binding<Bool>
    )

Basic usage ​

swift
Button("Options") {
    showOptions = true
}
.warpConfirmationDialog(
    title: "Choose an action",
    actions: [
        Warp.ConfirmationDialog.Action(title: "Share") { share() },
        Warp.ConfirmationDialog.Action(title: "Archive") { archive() }
    ],
    isPresented: $showOptions
)

With message ​

swift
Button("Delete") {
    showDeleteConfirmation = true
}
.warpConfirmationDialog(
    title: "Delete photo?",
    message: "This photo will be removed from your library.",
    actions: [
        Warp.ConfirmationDialog.Action(title: "Delete", style: .destructive) { deletePhoto() }
    ],
    isPresented: $showDeleteConfirmation
)

A Cancel button is provided automatically by the system. Do not add one manually.

Action styles ​

swift
enum Warp.ConfirmationDialog.Action.Style {
    /// A standard action button.
    case `default`
    /// A destructive action, displayed in red.
    case destructive
}

Parameters ​

Modifier props ​

NameTypeDefaultDescription
titleStringThe title displayed at the top of the dialog. Names the decision.
messageString?nilOptional message displayed below the title with additional context.
actions[Warp.ConfirmationDialog.Action]The actions to display. The system appends a Cancel button automatically.
isPresentedBinding<Bool>Controls the dialog's visibility. Set to true to present, false to dismiss.

Warp.ConfirmationDialog.Action ​

NameTypeDefaultDescription
titleStringThe action button label. Use a verb ("Delete", "Archive", "Share").
styleStyle.defaultVisual style of the button. Use .destructive for irreversible actions.
handler() -> VoidClosure executed when the action is tapped.

Questions? ​

Feel free to ask any questions on usage in the Warp DS Slack channel: #warp-design-system