SwiftUI appearsActive - Dim Views in Inactive Windows
When several windows share the screen, people need to see at a glance which one has focus. The Mac has always done this by dimming inactive windows. In iPadOS 27, iPad windows do the same: when someone moves to another window, the sidebar icons and text in the window they left fade, so the focused window stands out.
System views get this appearance without any code changes. Your custom views don't. A footer you drew yourself, a capsule filled with your accent color, or a badge built from shapes keeps its full color while everything around it fades, and the window looks half active.
The appearsActive environment value closes that gap. It tells a view whether its window should look active, so you can lower its opacity or swap its colors to match the system.
Note:
appearsActiveisn't new. It's available in iOS 18 and iPadOS 18 and later, and on macOS, SwiftUI back-deploys it to macOS 10.15. What's new in the 2027 releases is the iPad window appearance that makes it matter on iPad. All the behavior in this article was tested in the iPadOS 27.2 simulator with Windowed Apps turned on in Settings > Multitasking & Gestures.
Know What the System Dims for You
Before you write any code, check which parts of your interface already respond. In my testing with an iPad window in the inactive state:
- Sidebar rows dim. The labels and icons of a
Listin aNavigationSplitViewsidebar turn gray. - Custom views don't change. Shapes, custom fills, and text you style yourself keep their colors.
- Prominent buttons keep their tint. A button with the
.borderedProminentstyle stayed fully blue.
The last two cases are where appearsActive comes in. Look for views that draw attention with color, such as accent fills, progress indicators, badges, and icons with a strong tint, and decide how each should look when the window is in the background.
Dim a Custom View
Read the value with the @Environment property wrapper, then apply the change you want. The following footer shows storage usage at the bottom of a sidebar. It's built from text and two capsules, so the system has nothing to dim on its own:
struct StorageFooter: View {
@Environment(\.appearsActive) private var appearsActive
var usedFraction: Double = 0.68
var body: some View {
VStack(alignment: .leading, spacing: 6) {
Text("iCloud Storage")
.font(.subheadline.weight(.semibold))
Capsule()
.fill(.quaternary)
.frame(height: 6)
.overlay(alignment: .leading) {
GeometryReader { proxy in
Capsule()
.fill(.tint)
.frame(width: proxy.size.width * usedFraction)
}
}
Text("6.8 GB of 10 GB used")
.font(.caption)
.foregroundStyle(.secondary)
}
.padding()
.opacity(appearsActive ? 1 : 0.5)
}
}Place the footer in the sidebar with safeAreaInset(edge:alignment:spacing:content:), so it stays pinned below the list:
struct NotesSidebar: View {
@Binding var selection: Folder?
var body: some View {
List(Folder.allCases, selection: $selection) { folder in
Label(folder.title, systemImage: folder.symbol)
}
.navigationTitle("Notes")
.safeAreaInset(edge: .bottom) {
StorageFooter()
}
}
}Folder is a simple enumeration with a title and an SF Symbol name for each case.
Output:
Each time Settings takes focus, the sidebar rows and the storage footer fade together, and they return together when the Notes window is focused again. The readout in the middle of the window is a debug view, which you'll build later in this article.
SwiftUI updates every view that reads appearsActive when the value changes, so you don't need to observe any notifications yourself. The value comes from the window that contains the view, so each window of your app reflects its own state.
Replace the Accent Color
Opacity works well for secondary content. For a control that's filled with your accent color, swapping the color usually reads better than fading it, because a half-transparent accent still looks like it's asking for attention.
The following button style fills the capsule with the current tint when the window is active, and with a neutral gray fill when it isn't:
struct TintedCapsuleButtonStyle: ButtonStyle {
@Environment(\.appearsActive) private var appearsActive
func makeBody(configuration: Configuration) -> some View {
configuration.label
.font(.subheadline.weight(.semibold))
.foregroundStyle(appearsActive ? .white : .secondary)
.padding(.horizontal, 16)
.padding(.vertical, 8)
.background(
appearsActive ? AnyShapeStyle(.tint) : AnyShapeStyle(.fill.tertiary),
in: .capsule
)
.opacity(configuration.isPressed ? 0.7 : 1)
}
}Apply it like any other button style:
Button("New Note") {}
.buttonStyle(TintedCapsuleButtonStyle())Output:
Active window: the New Note button is filled with the accent color.
Inactive window: the New Note button switches to a gray fill, while the Share button with the borderedProminent style stays blue.
The Share button next to it uses the .borderedProminent style and keeps its blue fill in both states, which is why it's worth checking system styles as well as your own.
A style is a good place for this logic. Every button that uses it picks up the inactive appearance, and the views that create those buttons don't need to know about window state at all.
Tip: Change colors and opacity, not layout. Keep the size, position, and content of a view the same in both states, so nothing shifts when someone moves between windows.
Create a Reusable Modifier
If several views need the same treatment, move the environment read into a view modifier:
struct InactiveWindowDimming: ViewModifier {
@Environment(\.appearsActive) private var appearsActive
var opacity: Double
func body(content: Content) -> some View {
content.opacity(appearsActive ? 1 : opacity)
}
}
extension View {
/// Lowers the opacity of this view while its window appears inactive.
func dimmedWhenInactive(opacity: Double = 0.5) -> some View {
modifier(InactiveWindowDimming(opacity: opacity))
}
}Then apply it wherever you need it:
Label("Pinned", systemImage: "pin.fill")
.foregroundStyle(.orange)
.dimmedWhenInactive()
RoundedRectangle(cornerRadius: 8)
.fill(.indigo)
.frame(width: 160, height: 24)
.dimmedWhenInactive()These are the orange Pinned label and the indigo bar in the recording. Both fade with the rest of the window and return to full color when it's focused again.
The modifier reads the environment where it's applied, so it reflects the window that contains the view. You don't pass any state down from a parent.
Preview the Inactive Appearance
appearsActive is settable, so you can preview both states without arranging windows. Override the value with the environment(_:_:) modifier:
#Preview("Active window") {
StorageFooter()
}
#Preview("Inactive window") {
StorageFooter()
.environment(\.appearsActive, false)
}The override affects everything below it in the hierarchy. When I applied it to a whole NavigationSplitView in a running app, the system sidebar rows dimmed along with the custom views, even though the window had focus. Keep the override in previews and tests, and let the system set the value in your shipping app.
Don't Confuse appearsActive with scenePhase
appearsActive describes how a window should look. scenePhase describes the lifecycle of a scene. They answer different questions, and on iPad they disagree often.
The following readout shows both values side by side. It's the overlay you can see in the recording earlier in this article:
struct WindowStateReadout: View {
@Environment(\.appearsActive) private var appearsActive
@Environment(\.scenePhase) private var scenePhase
var body: some View {
VStack(alignment: .leading) {
Text("appearsActive: \(appearsActive ? "true" : "false")")
Text("scenePhase: \(String(describing: scenePhase))")
}
.font(.caption.monospaced())
.padding(8)
.background(.thinMaterial, in: .rect(cornerRadius: 8))
}
}When the Notes window loses focus to Settings, appearsActive changes to false, but scenePhase stays active. The window is still on screen and running. It just isn't the one people are working in.
| Question | Value to read |
|---|---|
| Should this view look focused or in the background? | appearsActive |
| Should the app pause work, save state, or release resources? | scenePhase |
Use appearsActive only for appearance. If you pause a timer or stop a video when a window loses focus, people lose that content the moment they glance at another window, even though they can still see it.
Important: Apple's documentation for
appearsActivesays the value is alwaystrueoutside macOS. That doesn't match iPadOS 27: in the iPadOS 27.2 simulator, an unfocused window reportedfalse, as the WWDC26 session What's new in SwiftUI describes. Don't assume the value is constant on any platform.
Summary
The system dims many standard views when a window loses focus, but it can't dim views it doesn't know about. appearsActive gives your custom views the same signal:
- Read
@Environment(\.appearsActive)and lower opacity, or swap accent fills for neutral ones, when the value isfalse. - Put the logic in a button style or view modifier, so it's written once and applied everywhere.
- Check system styles too. In my testing, sidebar rows dimmed but
.borderedProminentbuttons didn't. - Preview the inactive state with
.environment(\.appearsActive, false). - Keep appearance and lifecycle separate. An unfocused window still has a
scenePhaseofactive.
A few lines of code make every window in your app tell the same story, so people always know which window they're working in.
Thank you for reading. If you have any questions feel free to follow me on X and send me a DM. If this article helped you, Buy me a coffee.