Preview(_:traits:arguments:body:)
Creates a group of previews of a parameterized SwiftUI view, varying its inputs over the provided arguments.
Declaration
@freestanding(declaration) macro Preview<T>(_ name: String? = nil, traits: PreviewTrait<Preview.ViewTraits>..., arguments: [T], @ContentBuilder body: @escaping @MainActor (T) -> any View)Parameters
- name:
An optional display name for the preview. If you don’t specify a name, the canvas labels the preview using the line number where the preview appears in source.
- traits:
Optional Previewtrait instances that customizes the appearance of the preview.
- arguments:
An array of inputs to pass into the preview’s
body. - body:
A Contentbuilder mapping an argument to a SwiftUI view to preview.