<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 26.0.0 -",
    "watchOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/Preview(_:traits:arguments:body:)",
  "metadataVersion" : "0.1.0",
  "role" : "Macro",
  "symbol" : {
    "kind" : "Macro",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI7Preview_6traits9arguments4bodyySSSg_21DeveloperToolsSupport0C5TraitVyAgBV10ViewTraitsOGdSayxGAA0K0_pxScMYcctclufm"
  },
  "title" : "Preview(_:traits:arguments:body:)"
}
-->

# Preview(_:traits:arguments:body:)

Creates a group of previews of a parameterized SwiftUI view, varying its inputs
over the provided arguments.

```
@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
<doc://com.apple.documentation/documentation/DeveloperToolsSupport/PreviewTrait>
instances that customizes the appearance of the preview.

`arguments`

an array of inputs to pass into the preview’s `body`.

`body`

A [`ContentBuilder`](/documentation/SwiftUI/ContentBuilder) mapping an argument to a SwiftUI view to preview.

---

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)