---
title: OpenSettingsAction
framework: swiftui
role: symbol
role_heading: Structure
path: swiftui/opensettingsaction
---

# OpenSettingsAction

An action that presents the settings scene for an app.

## Declaration

```swift
@MainActor @preconcurrency struct OpenSettingsAction
```

## Overview

Overview Use the openSettings environment value to get the instance of this structure for a given Environment. Then call the instance to open a window. You call the instance directly because it defines a 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 }

## Topics

### Instance Methods

- [callAsFunction()](swiftui/opensettingsaction/callasfunction().md)

## Relationships

### Conforms To

- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Managing a settings window

- [Settings](swiftui/settings.md)
- [SettingsLink](swiftui/settingslink.md)
- [openSettings](swiftui/environmentvalues/opensettings.md)
