<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "visionOS: 26.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "DeveloperToolsSupport",
  "identifier" : "/documentation/DeveloperToolsSupport/Preview/init(_:as:widget:timeline:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "DeveloperToolsSupport"
    ],
    "preciseIdentifier" : "s:21DeveloperToolsSupport7PreviewV9WidgetKitE_2as6widget8timelineACSSSg_AD0E6FamilyOxycSayAD13TimelineEntry_pGyYaScMYcctc7SwiftUI0E0Rzlufc"
  },
  "title" : "init(_:as:widget:timeline:)"
}
-->

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

Creates a preview of a timeline-style widget.

```
@MainActor init(_ name: String? = nil, as family: WidgetFamily, widget: @escaping () -> some Widget, @PreviewTimelineBuilder timeline: @escaping @MainActor () async -> [any TimelineEntry])
```

## Discussion

The `#Preview` macro expands into a declaration that calls this initializer. To create a preview
that appears in the canvas, you must use the macro, not instantiate a Preview directly.

---

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)