How can I use SwiftUI tabview on macOS?
Asked on 2024-08-26
1 search
To use SwiftUI's TabView
on macOS, you can take advantage of the new features introduced in the latest updates. SwiftUI now allows you to style the TabView
to appear as a sidebar or as a segmented control in the toolbar. This is particularly useful for macOS applications where you might want to present a lot of content in a sidebar format.
To enable the sidebar with TabView
in SwiftUI, you should set the TabView
style to be sidebar adaptable. This can be done with a simple line of code, which will transform your tab bar into a sidebar, providing a more detailed and functional view. This approach is consistent across platforms, making it easier to maintain a unified look and feel in your app.
For more detailed guidance, you can refer to the session Elevate your tab and sidebar experience in iPadOS (06:41) which covers enabling the sidebar with TabView
in SwiftUI.

What’s new in SwiftUI
Learn how you can use SwiftUI to build great apps for any Apple platform. Explore a fresh new look and feel for tabs and documents on iPadOS. Improve your window management with new windowing APIs, and gain more control over immersive spaces and volumes in your visionOS apps. We’ll also take you through other exciting refinements that help you make expressive charts, customize and layout text, and so much more.

What’s new in AppKit
Discover the latest advances in Mac app development. Get an overview of the new features in macOS Sequoia, and how to adopt them in your app. Explore new ways to integrate your existing code with SwiftUI. Learn about the improvements made to numerous AppKit controls, like toolbars, menus, text input, and more.

Migrate your TVML app to SwiftUI
SwiftUI helps you build great apps on all Apple platforms and is the preferred toolkit for bringing your content into the living room with tvOS 18. Learn how to use SwiftUI to create familiar layouts and controls from TVMLKit, and get tips and best practices.