<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 11.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/WidgetConfiguration",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI19WidgetConfigurationP"
  },
  "title" : "WidgetConfiguration"
}
-->

# WidgetConfiguration

A type that describes a widget’s content.

```
@MainActor @preconcurrency protocol WidgetConfiguration
```

## Overview

A type conforming to this protocol inherits `@preconcurrency @MainActor`
isolation from the protocol if the conformance is included in the type’s
base declaration:

```
struct MyCustomType: Transition {
    // `@preconcurrency @MainActor` isolation by default
}
```

Isolation to the main actor is the default, but it’s not required. Declare
the conformance in an extension to opt out of main actor isolation:

```
extension MyCustomType: Transition {
    // `nonisolated` by default
}
```

## Topics

### Implementing a widget

[`body`](/documentation/SwiftUI/WidgetConfiguration/body-swift.property)

The content and behavior of this widget.

[`Body`](/documentation/SwiftUI/WidgetConfiguration/Body-swift.associatedtype)

The type of widget configuration representing the body of
this configuration.

### Setting a name

[`configurationDisplayName(_:)`](/documentation/SwiftUI/WidgetConfiguration/configurationDisplayName(_:))

Sets the localized name shown for a widget when a user adds or edits
the widget.

### Setting a description

[`description(_:)`](/documentation/SwiftUI/WidgetConfiguration/description(_:))

Sets the description shown for a widget when a user adds or edits it using the
contents of a text view.

### Setting the appearance

[`supportedFamilies(_:)`](/documentation/SwiftUI/WidgetConfiguration/supportedFamilies(_:))

Sets the sizes that a widget supports.

[`contentMarginsDisabled()`](/documentation/SwiftUI/WidgetConfiguration/contentMarginsDisabled())

Disable default content margins.

[`disfavoredLocations(_:for:)`](/documentation/SwiftUI/WidgetConfiguration/disfavoredLocations(_:for:))

Sets the disfavored locations for a widget.

[`containerBackgroundRemovable(_:)`](/documentation/SwiftUI/WidgetConfiguration/containerBackgroundRemovable(_:))

A modifier that marks the background of a widget as removable.

### Managing background tasks

[`backgroundTask(_:action:)`](/documentation/SwiftUI/WidgetConfiguration/backgroundTask(_:action:))

Runs the given action when the system provides a background task.

[`onBackgroundURLSessionEvents(matching:_:)`](/documentation/SwiftUI/WidgetConfiguration/onBackgroundURLSessionEvents(matching:_:))

Adds an action to perform when events related to a URL session identified by a
closure are waiting to be processed.



---

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)