SwiftUI MacOs Tabs

Viewed 787

I'm making a little helper app for myself in the MacOS, all using Swift + SwiftUI (newbie), but couldn't find a way to do these tabs:

MacOS Settings Tabs

Is there a specific way to create that interface with just SwiftUi, perhaps a library of sort? I did search for "SwiftUI tabs" but that only found the iOs tabs.

3 Answers

You should use TabView for MacOs as well

TabView {
    Text("This is the first tab") //Replace this with the view content for the first tab
        .tabItem {
            Text("Sound Effects")
        }

    Text("This is the second tab") //same here
        .tabItem {
            Text("Output")
        }

    Text("This is the third tab") //and here 
        .tabItem {
            Text("Input")
        }
}
struct ContentView: View {
    @State var selectorIndex = 0
    var body: some View {
        VStack {
            Picker("Numbers", selection: $selectorIndex) {
                ForEach(0 ..< 3) { index in
                    Text("\(index)")
                        .tag(index)
                }
            }
            .pickerStyle(SegmentedPickerStyle())
            Text("\(selectorIndex)")
                .font(.title)
            Spacer()
        }
    }
}
Related