<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: -",
    "macOS: 14.0.0 -",
    "visionOS: 26.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "WidgetKit",
  "identifier" : "/documentation/WidgetKit/Preview(_:as:using:widget:timelineProvider:)-3df1l",
  "metadataVersion" : "0.1.0",
  "role" : "Macro",
  "symbol" : {
    "kind" : "Macro",
    "modules" : [
      "WidgetKit"
    ],
    "preciseIdentifier" : "s:9WidgetKit7Preview_2as5using6widget16timelineProviderySSSg_AA0A6FamilyO6IntentQy_xycq_yctc7SwiftUI0A0RzAA0j8TimelineH0R_r0_lufm"
  },
  "title" : "Preview(_:as:using:widget:timelineProvider:)"
}
-->

# Preview(_:as:using:widget:timelineProvider:)

Preview a widget with an intent configuration, using the specified timeline provider.

```
@freestanding(declaration) macro Preview<Widget, Provider>(_ name: String? = nil, as family: WidgetFamily, using intent: Provider.Intent, widget: @escaping () -> Widget, timelineProvider: @escaping () -> Provider) where Widget : Widget, Provider : IntentTimelineProvider
```

## Parameters

`name`

An optional display name for the preview that appears in the Xcode preview canvas.

`family`

The widget family to display.

`intent`

The intent with which to configure the widget.

`widget`

A closure producing the widget to be previewed.

`timelineProvider`

A closure producing the timeline provider that generates the preview’s timeline.

## Overview

Provide the preview with sample data and use it to step through the timeline while ignoring the dates of the entries, and test out the transitions between them.

> Note: The timeline provider must be of the type that the widget expects.

---

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)