---
title: "Preview(_:traits:body:)"
framework: appkit
role: symbol
role_heading: Macro
path: "appkit/preview(_:traits:body:)-55ljx"
---

# Preview(_:traits:body:)

Preview an NSViewController.

## Declaration

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

## See Also

### Macros

- [NSIMAGE_UNAVAILABLE_MACCATALYST](appkit/nsimage_unavailable_maccatalyst.md)
- [NS_USER_ACTIVITY_SUPPORTED](appkit/ns_user_activity_supported.md)
- [Preview(_:traits:body:)](appkit/preview(_:traits:body:)-7pfjp.md)
