Set the Sidebar Initial Width in SwiftUI Navigation Split View
When you use a navigation split view in a SwiftUI Mac app, you normally have a sidebar in the left column. You want to give the sidebar an initial width that is wide enough to show the sidebar contents while letting people resize the sidebar. How do you provide the initial width?
Add the .navigationSplitViewColumnWidth
modifier to the sidebar view and supply the initial width you want. The following code sets the sidebar width to 192 points:
NavigationSplitView {
Sidebar()
.navigationSplitViewColumnWidth(ideal: 192)
} detail: {
DetailView()
}