Contents

StaticConfiguration

An object describing the content of a widget that has no user-configurable options.

Declaration

@MainActor @preconcurrency struct StaticConfiguration<Content> where Content : View

Mentioned in

Overview

The following example shows the configuration for the leaderboard widget of the Emoji Rangers: Supporting Live Activities, interactivity, and animations sample code project.

struct LeaderboardWidget: Widget {

    public var body: some WidgetConfiguration {
        StaticConfiguration(kind: EmojiRanger.LeaderboardWidgetKind, provider: LeaderboardProvider()) { entry in
            LeaderboardWidgetEntryView(entry: entry)
        }
        .configurationDisplayName("Ranger Leaderboard")
        .description("See all the rangers.")
        .supportedFamilies(LeaderboardWidget.supportedFamilies)
    }
}

Every widget has a unique kind, a string that you choose. You use this string to identify your widget when reloading its timeline with WidgetCenter.

The timeline provider is an object that determines the timeline for refreshing your widget. Providing future dates for updating your widget allows the system to optimize the refresh process.

The content closure contains the SwiftUI views that WidgetKit needs to render the widget. When WidgetKit invokes the content closure, it passes a timeline entry created by the widget provider’s getSnapshot(in:completion:) or getTimeline(in:completion:) method.

Modifiers let you specify the families your widget supports, and the details shown when users add or edit their widgets.

Topics

Creating a widget configuration

Setting the display name

Setting the description

Setting the supported families

Handling background network requests

See Also

Widget creation