WWDC22 SALE: Save 50% on all my Swift books and bundles! >>

SwiftUI: How do you restore a collapsed sidebar on macOS?

Forums > SwiftUI

Using Apple's Fruta example from WWDC, I've collapsed the sidebar I can't find a way to restore it (via code, UI, keyboard shortcut, or even a fresh build).

Does anyone know of a way to get the sidebar back?


yea it isnt the desired behavior. you can probably add a keyboard shortcut to set the sidebar back to its idealWidth. I am not at a computer right now so I cant try it Another option is to add a minimum width of 10 or something and display a button of some sorts to allow isers to reopen it.

in the meantime running "defaults delete com.youridentifier.yourapp" in a terminal will reset the application.

Edit: This doesn't appear to be the desired behavior in macOS at all. Most apps that have sidebars don't allow the sidebar to be collapsed and reopened by grabbing the side of the screen. XCode, Notes, etc have toolbar icons and keyboard shortcuts to reopen side menus. What you can do is add SidebarCommands() to the .commands of the WindowGroup. That will enable you to toggle the sidebar.


Thx @klheard for the cmd line fix.

Like @stuartbrekenridge, I ran into the missing sidebar in Apple SwiftUI Tutorial - Creating MacOS App. I was going nuts looking for what I messed up in the code. ;-)

Update: In the next section of the Apple SwiftUI Tutorial, they cover this situation. LOL! --> Apple SwiftUI Tutorial - Built in Menu Command


Very very thanks. I lost 48 hours when my app begun crash after i was set wrong language settings.

And your sample is very light and super


I found this article extremely helpful.


Save 50% in my Black Friday sale.

SAVE 50% To celebrate WWDC22, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.