<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/ToggleStyle/automatic",
  "metadataVersion" : "0.1.0",
  "role" : "Type Property",
  "symbol" : {
    "kind" : "Type Property",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI11ToggleStylePA2A07DefaultcD0VRszrlE9automaticAEvpZ"
  },
  "title" : "automatic"
}
-->

# automatic

The default toggle style.

```
@MainActor @export(implementation) @preconcurrency static var automatic: DefaultToggleStyle { get }
```

## Discussion

Use this [`ToggleStyle`](/documentation/SwiftUI/ToggleStyle) to let SwiftUI pick a suitable style for
the current platform and context. Toggles use the `automatic` style
by default, but you might need to set it explicitly using the
[`toggleStyle(_:)`](/documentation/SwiftUI/View/toggleStyle(_:)) modifier to override another style
in the environment. For example, you can request automatic styling for
a toggle in an [`HStack`](/documentation/SwiftUI/HStack) that’s otherwise configured to use the
[`button`](/documentation/SwiftUI/ToggleStyle/button) style:

```
HStack {
    Toggle(isOn: $isShuffling) {
        Label("Shuffle", systemImage: "shuffle")
    }
    Toggle(isOn: $isRepeating) {
        Label("Repeat", systemImage: "repeat")
    }

    Divider()

    Toggle("Enhance Sound", isOn: $isEnhanced)
        .toggleStyle(.automatic) // Set the style automatically here.
}
.toggleStyle(.button) // Use button style for toggles in the stack.
```

### Platform defaults

The `automatic` style produces an appearance that varies by platform,
using the following styles in most contexts:

|Platform   |Default style                                                         |
|-----------|----------------------------------------------------------------------|
|iOS, iPadOS|``doc://com.apple.SwiftUI/documentation/SwiftUI/ToggleStyle/switch``  |
|macOS      |``doc://com.apple.SwiftUI/documentation/SwiftUI/ToggleStyle/checkbox``|
|tvOS       |``doc://com.apple.SwiftUI/documentation/SwiftUI/ToggleStyle/switch``  |
|watchOS    |``doc://com.apple.SwiftUI/documentation/SwiftUI/ToggleStyle/switch``  |

The default style for tvOS behaves like a button. However,
unlike the [`switch`](/documentation/SwiftUI/ToggleStyle/switch) style that’s on other platforms, the
tvOS toggle takes as much horizontal space as its parent offers, and
displays both the toggle’s label and a text field that indicates the
toggle’s state. You typically collect tvOS toggles into a [`List`](/documentation/SwiftUI/List):

```
List {
    Toggle("Show Lyrics", isOn: $isShowingLyrics)
    Toggle("Shuffle", isOn: $isShuffling)
    Toggle("Repeat", isOn: $isRepeating)
}
```

![A screenshot of three buttons labeled Show Lyrics, Shuffle, and](images/com.apple.SwiftUI/ToggleStyle-automatic-2-tvOS@2x.png)

### Contextual defaults

A toggle’s automatic appearance varies in certain contexts:

- A toggle that appears as part of the content that you provide to one
  of the toolbar modifiers, like [`toolbar(content:)`](/documentation/SwiftUI/View/toolbar(content:)), uses
  the [`button`](/documentation/SwiftUI/ToggleStyle/button) style by default.
- A toggle in a [`Menu`](/documentation/SwiftUI/Menu) uses a style that you can’t create explicitly:
  
  ```
  Menu("Playback") {
      Toggle("Show Lyrics", isOn: $isShowingLyrics)
      Toggle("Shuffle", isOn: $isShuffling)
      Toggle("Repeat", isOn: $isRepeating)
  }
  ```
  
  SwiftUI shows the toggle’s label with a checkmark that appears only
  in the `on` state:
  
  |Platform   |Appearance                                                                                                                                                                                                                                                     |
  |-----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
  |iOS, iPadOS|![A screenshot of a Playback menu in iOS showing three menu items with the labels Repeat, Shuffle, and Show Lyrics. The shuffle item has a checkmark to its left, while the other two items have a blank space to their left.](ToggleStyle-automatic-1-iOS)    |
  |macOS      |![A screenshot of a Playback menu in macOS showing three menu items with the labels Repeat, Shuffle, and Show Lyrics. The shuffle item has a checkmark to its left, while the other two items have a blank space to their left.](ToggleStyle-automatic-1-macOS)|

---

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)