Contents

WidgetPreviewContext

A specification for the context of a widget preview.

Declaration

struct WidgetPreviewContext

Overview

To create a preview for a widget in Xcode, use previewContext(_:) and pass WidgetPreviewContext initialized with the appropriate WidgetFamily.

struct Widget_Previews: PreviewProvider {
    static var previews: some View {
        Group {
            MyWidgetView()
                .previewContext(WidgetPreviewContext(family: .systemSmall))
        }
    }
}

Topics

Creating a Preview Context

See Also

Previews and debugging