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.
Hold a brightness with the
ImmersiveContentBrightnesstypeThe 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.Pick a level from the standard constants
ImmersiveContentBrightnessexposes 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.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 aText, which is a convenient way to confirm whichImmersiveContentBrightnessconstant is active.Apply it where the immersive space is declared
An
ImmersiveContentBrightnessonly takes effect on anImmersiveSpace, through the immersive-style configuration — the captionApplied via .immersionStyle / immersiveContentBrightness on an ImmersiveSpacemarks that connection point. The surroundingVStackhere is just a panel that reports the setting; the symbol itself plugs into the space's scene declaration.
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.
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()
}
}