<!--
{
  "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/makeBody(configuration:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI11ToggleStyleP8makeBody13configuration0F0QzAA0cD13ConfigurationV_tF"
  },
  "title" : "makeBody(configuration:)"
}
-->

# makeBody(configuration:)

Creates a view that represents the body of a toggle.

```
@ContentBuilder @MainActor @preconcurrency func makeBody(configuration: Self.Configuration) -> Self.Body
```

## Parameters

`configuration`

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

## Return Value

A view that has behavior and appearance that enables it
to function as a [`Toggle`](/documentation/SwiftUI/Toggle).

## Discussion

Implement this method when you define a custom toggle style that
conforms to the [`ToggleStyle`](/documentation/SwiftUI/ToggleStyle) protocol. Use the `configuration`
input — a [`ToggleStyleConfiguration`](/documentation/SwiftUI/ToggleStyleConfiguration) instance — to access the
toggle’s label and state. Return a view that has the appearance and
behavior of a toggle. For example you can create a toggle that displays
a label and a circle that’s either empty or filled with a checkmark:

```
struct ChecklistToggleStyle: ToggleStyle {
    func makeBody(configuration: Configuration) -> some View {
        Button {
            configuration.isOn.toggle()
        } label: {
            HStack {
                Image(systemName: configuration.isOn
                        ? "checkmark.circle.fill"
                        : "circle")
                configuration.label
            }
        }
        .tint(.primary)
        .buttonStyle(.borderless)
    }
}
```

The `ChecklistToggleStyle` toggle style provides a way to both observe
and modify the toggle state: the circle fills for the on state, and
users can tap or click the toggle to change the state. By using a
customized [`Button`](/documentation/SwiftUI/Button) to compose the toggle’s body, SwiftUI
automatically provides the behaviors that users expect from a
control that has button-like characteristics.

You can present a collection of toggles that use this style in a stack:

![A screenshot of three items stacked vertically. All have a circle](images/com.apple.SwiftUI/ToggleStyle-makeBody-1-iOS@2x.png)

When updating a view hierarchy, the system calls your implementation
of the `makeBody(configuration:)` method for each [`Toggle`](/documentation/SwiftUI/Toggle) instance
that uses the associated style.

### Modify the current style

Rather than create an entirely new style, you can alternatively
modify a toggle’s current style. Use the [`init(_:)`](/documentation/SwiftUI/Toggle/init(_:))
initializer inside the `makeBody(configuration:)` method to create
and modify a toggle based on a `configuration` value. For example,
you can create a style that adds padding and a red border to the
current style:

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

If you create a `redBorder` static variable from this style,
you can apply the style to toggles that already use another style, like
the built-in [`switch`](/documentation/SwiftUI/ToggleStyle/switch) and [`button`](/documentation/SwiftUI/ToggleStyle/button) styles:

```
Toggle("Switch", isOn: $isSwitchOn)
    .toggleStyle(.redBorder)
    .toggleStyle(.switch)

Toggle("Button", isOn: $isButtonOn)
    .toggleStyle(.redBorder)
    .toggleStyle(.button)
```

Both toggles appear with the usual styling, each with a red border:

![A screenshot of a switch toggle with a red border, and a button](images/com.apple.SwiftUI/ToggleStyle-makeBody-2-iOS@2x.png)

Apply the custom style closer to the toggle than the
modified style because SwiftUI evaluates style view modifiers in order
from outermost to innermost. If you apply the styles in the other
order, the red border style doesn’t have an effect, because the
built-in styles override it completely.

---

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)