Skip to main content
.toolbar(content: ToolbarItem | ToolbarItemGroup | Group | (ToolbarItem | ToolbarItemGroup)[]): Component;

Parameters

content
ToolbarItem | ToolbarItemGroup | Group | (ToolbarItem | ToolbarItemGroup)[]
The toolbar content to display. Can be a single toolbar item, group, or an array of toolbar items. Use ToolbarItem() or ToolbarItemGroup() to create toolbar elements.

Support

Usage

Basic toolbar with buttons

NavigationView([
    VStack([
        Text("Main Content")
    ])
]).toolbar(
    ToolbarItem({ placement: "navigationBarTrailing" }, [
        Button("Edit", () => {
            editItem();
        })
    ])
)

Toolbar with multiple items

NavigationView([
    List([
        ForEach(items, (item) =>
            ItemRow(item)
        )
    ])
]).toolbar(
    ToolbarItemGroup({ placement: "navigationBarTrailing" }, [
        Button("Cancel", () => {
            cancelAction();
        }),
        Button("Save", () => {
            saveAction();
        })
    ])
)