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

# Preview(_:traits:body:)

Preview an NSViewController.

```
@freestanding(declaration) macro Preview(_ name: String? = nil, traits: PreviewTrait<Preview.ViewTraits>..., @PreviewMacroBodyBuilder<NSViewController> body: @escaping @MainActor () -> NSViewController)
```

## Parameters

`name`

Optional display name for the preview, which will appear in the canvas.

`traits`

Optional list of traits customizing the appearance of the preview.

`body`

A closure producing an NSViewController.

---

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)