How it works
WindowToolbarFullScreenVisibility describes how a window's toolbar behaves once that window enters full-screen mode on macOS. By default a toolbar slides out of the way to give content the entire screen, but some apps want it to stay put or to reveal itself when the pointer approaches the top edge. Reach for this type, together with the scene-level modifier that accepts it, when you need to control that trade-off between immersive content and a persistently reachable toolbar.
Choose a value with the static cases
WindowToolbarFullScreenVisibility is a small value type whose meaning is carried entirely by its cases:
.automaticlets the system decide based on context,.onHoverkeeps the toolbar hidden until the pointer reaches the top of the window, and.visiblepins it on screen throughout full screen. The example selects among these three withWindowToolbarFullScreenVisibility.automatic,.onHover, and.visible.Hold the choice in state
Because the value is a plain, comparable type, it stores cleanly in view state and can be mutated as the user changes their mind. Here
@State private var visibility: WindowToolbarFullScreenVisibility = .automaticseeds the choice and gives the controls something to bind to.Bind it to a control
Each case is equatable and hashable, so it works as a selection value out of the box. The
Picker("Visibility", selection: $visibility)drivesvisibilitydirectly, and each option is identified with.tag(WindowToolbarFullScreenVisibility.automatic)and the matching tags for.onHoverand.visible.Apply it at the scene
The visibility is a property of a window rather than of any single view, so in a full app you hand the resolved value to the scene that hosts the window, where SwiftUI applies it the next time that window goes full screen. In this isolated demo the value lives in
visibility, ready to be passed up to that scene-level modifier.
@State private var visibility: WindowToolbarFullScreenVisibility = .visible to see which case the picker reports as selected on launch.Example & preview
Press Run live & edit to compile it in your browser — then edit the Swift on the left and the preview re-renders live.
struct WindowToolbarFullScreenVisibilityDemo: View {
@State private var visibility: WindowToolbarFullScreenVisibility = .automatic
var body: some View {
VStack(alignment: .leading, spacing: 12) {
Text("Full-Screen Toolbar")
.font(.headline)
Text("In full screen, the window toolbar visibility is set per scene.")
.font(.caption)
.foregroundStyle(.secondary)
Picker("Visibility", selection: $visibility) {
Text("Automatic").tag(WindowToolbarFullScreenVisibility.automatic)
Text("On Hover").tag(WindowToolbarFullScreenVisibility.onHover)
Text("Visible").tag(WindowToolbarFullScreenVisibility.visible)
}
.pickerStyle(.segmented)
}
.padding()
}
}