Contents

accessoryBar

A button style that is typically used in the context of an accessory toolbar (sometimes refererred to as a “scope bar”), for buttons that narrow the focus of a search or other operation.

Declaration

@MainActor @preconcurrency static var accessoryBar: AccessoryBarButtonStyle { get }

Discussion

This is the default button style for views in accessory toolbars, created with ToolbarItemPlacement.init(id:_), and for searchable scopes.

This style will also affect button style Toggles, as well as button style Pickers and Menus.

HStack(alignment: .firstTextBaseline) {
    Button("Button") {}

    Toggle("Toggle", isOn: $isToggleOn)
        .toggleStyle(.button)

    Picker("Picker", selection: $selection) {
        Text("Option 1").tag(0)
        Text("Option 2").tag(1)
    }

    Picker("Inline Picker", selection: $selection) {
        Text("Option 1").tag(0)
        Text("Option 2").tag(1)
    }
    .pickerStyle(.inline)

    Menu("Menu") {
        Button("Item") {}
    }
}
.buttonStyle(.accessoryBar)

See Also

Getting built-in button styles