---
title: WidgetPreviewContext
framework: widgetkit
role: symbol
role_heading: Structure
path: widgetkit/widgetpreviewcontext
---

# WidgetPreviewContext

A specification for the context of a widget preview.

## Declaration

```swift
struct WidgetPreviewContext
```

## Overview

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

- [init(family:)](widgetkit/widgetpreviewcontext/init(family:).md)

## Relationships

### Conforms To

- [PreviewContext](swiftui/previewcontext.md)

## See Also

### Previews and debugging

- [Previewing widgets and Live Activities in Xcode](widgetkit/previewing-widgets-and-live-activities-in-xcode.md)
- [Preview macros](widgetkit/preview-macros.md)
