Type Property 型プロパティ

destructive

A role that indicates a destructive button.

Declaration 宣言

static let destructive: ButtonRole

Discussion 議論

Use this role for a button that deletes user data, or performs an irreversible operation. A destructive button signals by its appearance that the user should carefully consider whether to tap or click the button. For example, SwiftUI presents a destructive button that you add with the swipeActions(edge:allowsFullSwipe:content:) modifier using a red background:


List {
    ForEach(items) { item in
        Text(item.title)
            .swipeActions {
                Button(role: .destructive) { delete() } label: {
                    Label("Delete", systemImage: "trash")
                }
            }
    }
}
.navigationTitle("Shopping List")

A screenshot of a list of three items, where the second item is

See Also 参照

Getting Button Roles