I have two views with .searchable modifier and different placements. In both cases the search bar takes a humongous space in the toolbar, thing that doesn't happen in other apps (Apple native ones, like Mail and Contacts). What am I doing wrong? I want the search bar to be atmost the space it occupies on the native apps, but instead it takes space from other very important buttons on the toolbar.
I'm using macOS Tahoe Public Beta 4 (25A5346a)
.toolbar {
ToolbarSpacer(.flexible)
ToolbarItem {
Button { refresh() } label: {
Label(
"Refresh categories",
systemImage: "arrow.trianglehead.2.clockwise.rotate.90"
)
.labelStyle(.iconOnly)
}
}
ToolbarSpacer(.fixed)
ToolbarItem {
Button {
filters.isListFilterVisible = true
} label: {
Label("Filter list", systemImage: "line.3.horizontal.decrease")
.labelStyle(.iconOnly)
.foregroundStyle(.primary)
}
.popover(
isPresented: $filters.isListFilterVisible,
arrowEdge: .bottom
) {
MonthYearPicker($filters.date)
.frame(minWidth: 180)
.padding(.medium)
}
.buttonStyle(.borderedProminent)
.tint(
filters.hasFilteredDate ? .accent : .secondary.opacity(0)
)
}
ToolbarSpacer(.fixed)
ToolbarItem {
Button {
isCreationSheetVisible = true
} label: {
Label("Add category", systemImage: "plus")
.bold()
.labelStyle(.iconOnly)
}
}
}
View1 using
.searchable(text: $filters.searchQuery, placement: .toolbarPrincipal)

View2 using
.searchable(text: $filters.searchQuery, placement: .toolbar)

ToolbarSpacer. Unfortunately, I don't have macOS 26, so I didn't try it already.