TechnologiesSwiftUI

EmptyWidgetConfiguration struct

iOSmacOStvOSwatchOSvisionOS✓ renders

An empty widget configuration.

How it works

EmptyWidgetConfiguration is a WidgetConfiguration that contains no content and performs no work. It exists as a neutral, do-nothing value that conforms to the WidgetConfiguration protocol, so you can return it wherever a configuration is required but you have nothing meaningful to declare. Reach for it as a placeholder while you scaffold a widget, or as a branch result when a conditional configuration needs a valid "nothing here" case.

  1. Satisfy WidgetConfiguration with no body

    Because EmptyWidgetConfiguration conforms to WidgetConfiguration, it can stand in for any configuration a widget's body expects, while declaring no kind, no provider, and no view. In the demo the symbol's name is surfaced as plain text via Text("EmptyWidgetConfiguration") so you can see where it would otherwise plug into a widget's configuration.

  2. Use it as a typed placeholder

    Returning EmptyWidgetConfiguration gives you a concrete, type-checked value to hand back before the real configuration exists, keeping the widget compilable as you build it out. The card here uses the Image(systemName: "square.dashed") glyph to signal that empty, not-yet-filled state.

  3. Branch a conditional configuration to an empty case

    When you build a configuration conditionally, every branch must produce a WidgetConfiguration; EmptyWidgetConfiguration is the legal "produce nothing" branch that lets the other branch supply the real configuration. The Text("My Widget") heading marks the slot a populated configuration would normally fill.

  4. Compose without adding behavior

    EmptyWidgetConfiguration carries no timeline provider and renders no widget, so combining it into a configuration adds nothing and changes nothing observable. In the example it is presented inside a passive layout, padded and wrapped in a RoundedRectangle(cornerRadius: 20) background, purely to label the symbol rather than to drive any widget behavior.

Try it — Change Text("EmptyWidgetConfiguration") to Text("No configuration") to reinforce that the symbol stands for an intentionally empty, no-op configuration.

Example & preview

Press Run live & edit to compile it in your browser — then edit the Swift on the left and the preview re-renders live.

EmptyWidgetConfiguration.swift
struct EmptyWidgetConfigurationDemo: View {
    var body: some View {
        VStack(alignment: .leading, spacing: 8) {
            Image(systemName: "square.dashed")
                .font(.title)
                .foregroundStyle(.tint)
            Text("My Widget")
                .font(.headline)
            Text("EmptyWidgetConfiguration")
                .font(.caption)
                .foregroundStyle(.secondary)
        }
        .padding()
        .frame(width: 150, height: 150)
        .background(.quaternary, in: RoundedRectangle(cornerRadius: 20))
        .padding()
    }
}
Live preview
My Widget EmptyWidgetConfiguration
My Widget EmptyWidgetConfiguration
swift → lexer → parser → sema → uiir → canvas Open in Studio ↗
What's new in SwiftUI 27 →