<!--
{
  "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:widget:timeline:)",
  "metadataVersion" : "0.1.0",
  "role" : "Macro",
  "symbol" : {
    "kind" : "Macro",
    "modules" : [
      "WidgetKit"
    ],
    "preciseIdentifier" : "s:9WidgetKit7Preview_2as6widget8timelineySSSg_AA0A6FamilyOxycSayAA13TimelineEntry_pGyYaScMYcctc7SwiftUI0A0Rzlufm"
  },
  "title" : "Preview(_:as:widget:timeline:)"
}
-->

# Preview(_:as:widget:timeline:)

Preview a timeline-style widget.

```
@freestanding(declaration) macro Preview<Widget>(_ name: String? = nil, as family: WidgetFamily, widget: @escaping () -> Widget, @PreviewTimelineBuilder timeline: @escaping @MainActor () async -> [any TimelineEntry]) where Widget : Widget
```

## Parameters

`name`

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

`family`

The widget family to display.

`widget`

A closure producing the widget to be previewed.

`timeline`

A closure building the timeline of entries to be previewed.

## 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 entries 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)