Contents

Preview(_:as:widget:timeline:)

Preview a timeline-style widget.

Declaration

@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.

Mentioned in

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.

See Also

Generating a widget preview