TechnologiesSwiftUIImmersive Spaces and visionOS

ImmersiveContentBrightness struct

iOSmacOStvOSwatchOSvisionOS✓ renders

The content brightness of an immersive space.

How it works

ImmersiveContentBrightness is a set of constants that tell SwiftUI how bright the content of an immersive space should appear on visionOS. When you open a fully immersive space, the system needs to know whether your scene should glow at its native intensity or be dimmed so it sits comfortably in the wearer's surroundings — this type names those choices. Reach for it when you present an ImmersiveSpace and want explicit control over its luminance rather than accepting the default.

  1. Hold a brightness with the ImmersiveContentBrightness type

    The type is a value you store and pass along, not something you compute. In the example the chosen setting is kept in a single property, private let brightness: ImmersiveContentBrightness = .dim, so the rest of the view can read it and ultimately hand it to the immersive space.

  2. Pick a level from the standard constants

    ImmersiveContentBrightness exposes named cases for the common intensities — here the code selects .dim, the toned-down level that keeps an immersive scene from overpowering the room. Swapping the constant is all it takes to move between brightness levels; no other code changes.

  3. Inspect the chosen value

    Because it is an ordinary value, you can surface it for debugging or display. The example renders the current setting with String(describing: brightness) inside a Text, which is a convenient way to confirm which ImmersiveContentBrightness constant is active.

  4. Apply it where the immersive space is declared

    An ImmersiveContentBrightness only takes effect on an ImmersiveSpace, through the immersive-style configuration — the caption Applied via .immersionStyle / immersiveContentBrightness on an ImmersiveSpace marks that connection point. The surrounding VStack here is just a panel that reports the setting; the symbol itself plugs into the space's scene declaration.

Try it — Change private let brightness: ImmersiveContentBrightness = .dim to a brighter constant and watch the Text("Setting: ...") line update to the new value.

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.

ImmersiveContentBrightness.swift
struct ImmersiveContentBrightnessDemo: View {
    private let brightness: ImmersiveContentBrightness = .dim

    var body: some View {
        VStack(spacing: 12) {
            Label("Immersive Brightness", systemImage: "sun.max")
                .font(.headline)
            Text("Setting: \(String(describing: brightness))")
                .foregroundStyle(.secondary)
            Text("Applied via .immersionStyle / immersiveContentBrightness on an ImmersiveSpace")
                .font(.caption)
                .multilineTextAlignment(.center)
        }
        .padding()
    }
}
Live preview
Immersive Brightness Setting: {String(describing: brightness)} Applied via .immersionStyle / immersiveContentBrightness on an ImmersiveSpace
Immersive Brightness Setting: {String(describing: brightness)} Applied via .immersionStyle / immersiveContentBrightness on an ImmersiveSpace
swift → lexer → parser → sema → uiir → canvas Open in Studio ↗
What's new in SwiftUI 27 →