ButtonToggleStyle
A toggle style that displays as a button with its label as the title.
Platform Compatibility
Tags
SwiftUI Code
@State var isOn = false
var body: some View {
List {
Toggle("Foo1", isOn: $isOn)
Toggle("Foo2", image: .cats24X24, isOn: $isOn)
Toggle("Foo3", systemImage: "star", isOn: $isOn)
Toggle(isOn: $isOn) {
Label("Foo4", systemImage: "star")
Text("Bar")
}
Toggle("Foo5", isOn: .constant(true))
}
.toggleStyle(.button)
}Found an issue or have a suggestion?
More Toggle Components
View allMultiple Sources Toggle
Creates a toggle that updates the selected property for all sources. Once toggled, all sources will have the same value.
Explore Other Components
Browse allIcon Phase Store View
Creates a view to load a collection of products from the App Store using product identifiers, and merchandise them using their promotional images and a custom placeholder icon.
Image Label
Creates a label with an icon image and a title generated from a localized string.
Reserved Regions
Returns the reserved regions for the given kind. A reserved region indicates that an area within a view’s coordinate space has been claimed by something the view does not own
ToolbarItem Shared Background Visibility
Controls the visibility of the glass background effect on items in the toolbar. In certain contexts, such as the navigation bar on iOS and the window toolbar on macOS, toolbar items will be given a glass background effect that is shared with other items in the same logical grouping