<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "DeveloperToolsSupport",
  "identifier" : "/documentation/DeveloperToolsSupport/Preview/init(_:traits:body:cameras:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "DeveloperToolsSupport"
    ],
    "preciseIdentifier" : "s:21DeveloperToolsSupport7PreviewV7SwiftUIE_6traits4body7camerasACSSSg_AA0D5TraitVyAC10ViewTraitsOGdAD0K0_pyScMYccSayAA0D6CameraVGyXEtcfc"
  },
  "title" : "init(_:traits:body:cameras:)"
}
-->

# init(_:traits:body:cameras:)

Creates a preview of a SwiftUI view using the specified traits and
custom viewpoints.

```
@MainActor init(_ name: String? = nil, traits: PreviewTrait<Preview.ViewTraits>..., @ContentBuilder body: @escaping @MainActor () -> any View, @PreviewCameraBuilder cameras: () -> [PreviewCamera])
```

## Parameters

`name`

An optional display name for the preview.

`traits`

An optional list of
<doc://com.apple.documentation/documentation/DeveloperToolsSupport/PreviewTrait>
instances that customize the appearance of the preview.

`body`

A content builder that produces a SwiftUI view to preview.

`cameras`

One or more preview cameras that indicate the custom, fixed
viewpoints that you want to be able to view the preview from.

## Discussion

Preview macros expand into a declaration that calls this initializer.
Don’t use this initializer directly. Instead use one of the macros, like
<doc://com.apple.documentation/documentation/SwiftUI/Preview(_:traits:body:cameras:)>.

---

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)