<!--
{
  "availability" : [
    "macOS: 14.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/EnvironmentValues/openSettings",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI17EnvironmentValuesVAAE12openSettingsAA04OpenF6ActionVvp"
  },
  "title" : "openSettings"
}
-->

# openSettings

A Settings presentation action stored in a view’s environment.

```
var openSettings: OpenSettingsAction { get }
```

## Discussion

Use the `openSettings` environment value to get an
[`OpenSettingsAction`](/documentation/SwiftUI/OpenSettingsAction) instance for a given [`Environment`](/documentation/SwiftUI/Environment). Then call
the instance to open a window. You call the instance directly because it
defines a [`callAsFunction()`](/documentation/SwiftUI/OpenSettingsAction/callAsFunction()) method that Swift
calls when you call the instance.

For example, you can define a button that opens the settings window to
a particular tab:

```
@main
struct MyApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
        #if os(macOS)
        Settings {
            SettingsView()
        }
        #endif
    }
}

struct SettingsView: View {
    @AppStorage("selectedSettingsTab")
    private var selectedSettingsTab = SettingsTab.general

    var body: some View {
        TabView(selection: $selectedSettingsTab) {
            GeneralSettings()
            AdvancedSettings()
        }
    }
}

struct AdvancedSettingsButton: View {
    @AppStorage("selectedSettingsTab")
    private var selectedSettingsTab = SettingsTab.general

    @Environment(\.openSettings) private var openSettings

    var body: some View {
        Button("Open Advanced Settings…") {
            selectedSettingsTab = .advanced
            openSettings()
        }
    }
}

enum SettingsTab: Int {
    case general
    case advanced
}
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)