<!--
{
  "availability" : [
    "macOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/Preview(_:traits:arguments:body:)-5hzef",
  "metadataVersion" : "0.1.0",
  "role" : "Macro",
  "symbol" : {
    "kind" : "Macro",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "s:6AppKit7Preview_6traits9arguments4bodyySSSg_21DeveloperToolsSupport0C5TraitVyAgBV10ViewTraitsOGdSayxGSo6NSViewCxScMYcctclufm"
  },
  "title" : "Preview(_:traits:arguments:body:)"
}
-->

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

Creates a group of previews of an NSView.

```
@freestanding(declaration) macro Preview<T>(_ name: String? = nil, traits: PreviewTrait<Preview.ViewTraits>..., arguments: [T], @PreviewBodyBuilder<NSView> body: @escaping @MainActor (T) -> NSView)
```

## Parameters

`name`

An optional display name for the preview.

`traits`

An optional list of traits to customize the preview.

`arguments`

An array of arguments to pass into `body`.

`body`

A closure that maps an argument to an NSView 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)