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

# switch

A toggle style that displays a leading label and a trailing switch.

```
@export(implementation) nonisolated static var `switch`: SwitchToggleStyle { get }
```

## Discussion

Apply this style to a [`Toggle`](/documentation/SwiftUI/Toggle) or to a view hierarchy that contains
toggles using the [`toggleStyle(_:)`](/documentation/SwiftUI/View/toggleStyle(_:)) modifier:

```
Toggle("Enhance Sound", isOn: $isEnhanced)
    .toggleStyle(.switch)
```

The style produces a label that describes the purpose of the toggle
and a switch that shows the toggle’s state. The user taps or clicks
the switch to change the toggle’s state. The default appearance is
similar across platforms, although the way you use switches in your
user interface varies a little, as described in
<doc://com.apple.documentation/design/Human-Interface-Guidelines/toggles>
in the Human Interface Guidelines.

**iOS:**

![A screenshot of the text On appearing to the left of a toggle switch that's on. The toggle's tint color is green. The toggle and its text appear in a rounded rectangle, and are aligned with opposite edges of the rectangle.](images/com.apple.SwiftUI/ToggleStyle-switch-1-iOS~dark@2x.png)

**macOS:**

![A screenshot of the text On appearing to the left of a toggle switch that's on. The toggle's tint color is blue. The toggle and its text are adjacent to each other.](images/com.apple.SwiftUI/ToggleStyle-switch-1-macOS~dark@2x.png)

**watchOS:**

![A screenshot of the text On appearing to the left of a toggle switch that's on. The toggle's tint color is green. The toggle and its text appear in a rounded rectangle, and are aligned with opposite edges of the rectangle.](images/com.apple.SwiftUI/ToggleStyle-switch-1-watchOS@2x.png)

**tvOS:**

![A screenshot of three buttons labeled Show Lyrics, Shuffle, and Repeat, stacked vertically. The first is highlighted. The second is on, while the others are off.](images/com.apple.SwiftUI/ToggleStyle-automatic-2-tvOS~dark@2x.png)

In iOS, iPadOS, watchOS, and tvOS, the label and switch fill as much
horizontal space as the toggle’s parent offers by aligning the label’s
leading edge and the switch’s trailing edge with the containing view’s
respective leading and trailing edges. In macOS, the style uses a
minimum of horizontal space by aligning the trailing edge of the label
with the leading edge of the switch. SwiftUI helps you to manage the
spacing and alignment when this style appears in a [`Form`](/documentation/SwiftUI/Form).

SwiftUI uses this style as the default for iOS, iPadOS, watchOS, and
tvOS in most contexts when you don’t set a style, or when you apply
the [`automatic`](/documentation/SwiftUI/ToggleStyle/automatic) style.

---

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)