TechnologiesSwiftUI

WindowToolbarFullScreenVisibility struct

iOSmacOStvOSwatchOSvisionOSiOS 18.0+✓ renders

The visibility of the window toolbar with respect to full screen mode.

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.

  1. Choose a value with the static cases

    WindowToolbarFullScreenVisibility is a small value type whose meaning is carried entirely by its cases: .automatic lets the system decide based on context, .onHover keeps the toolbar hidden until the pointer reaches the top of the window, and .visible pins it on screen throughout full screen. The example selects among these three with WindowToolbarFullScreenVisibility.automatic, .onHover, and .visible.

  2. 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 = .automatic seeds the choice and gives the controls something to bind to.

  3. 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) drives visibility directly, and each option is identified with .tag(WindowToolbarFullScreenVisibility.automatic) and the matching tags for .onHover and .visible.

  4. 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.

Try it — Change the initial state to @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.

WindowToolbarFullScreenVisibility.swift
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()
    }
}
Live preview
Full-Screen Toolbar In full screen, the window toolbar visibility is set per scene. Automatic On Hover Visible
Full-Screen Toolbar In full screen, the window toolbar visibility is set per scene. Automatic On Hover Visible
swift → lexer → parser → sema → uiir → canvas Open in Studio ↗
What's new in SwiftUI 27 →