<!--
{
  "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/Toggle/init(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI6ToggleVA2A0C18StyleConfigurationV5LabelVRszrlEyACyAGGAEcfc"
  },
  "title" : "init(_:)"
}
-->

# init(_:)

Creates a toggle based on a toggle style configuration.

```
nonisolated init(_ configuration: ToggleStyleConfiguration)
```

## Parameters

`configuration`

The properties of the toggle, including a
label and a binding to the toggle’s state.

## Discussion

You can use this initializer within the
[`makeBody(configuration:)`](/documentation/SwiftUI/ToggleStyle/makeBody(configuration:)) method of a [`ToggleStyle`](/documentation/SwiftUI/ToggleStyle) to
create an instance of the styled toggle. This is useful for custom
toggle styles that only modify the current toggle style, as opposed to
implementing a brand new style.

For example, the following style adds a red border around the toggle,
but otherwise preserves the toggle’s current style:

```
struct RedBorderToggleStyle: ToggleStyle {
    func makeBody(configuration: Configuration) -> some View {
        Toggle(configuration)
            .padding()
            .border(.red)
    }
}
```

---

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)