<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "DeveloperToolsSupport",
  "identifier" : "/documentation/DeveloperToolsSupport/PreviewTrait",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "DeveloperToolsSupport"
    ],
    "preciseIdentifier" : "s:21DeveloperToolsSupport12PreviewTraitV"
  },
  "title" : "PreviewTrait"
}
-->

# PreviewTrait

Customizations that you can apply to a preview.

```
@MainActor struct PreviewTrait<T>
```

## Topics

### Getting a layout

[`defaultLayout`](/documentation/DeveloperToolsSupport/PreviewTrait/defaultLayout)

Center the preview in a container the size of the device on which the
preview is running.

[`fixedLayout(width:height:)`](/documentation/DeveloperToolsSupport/PreviewTrait/fixedLayout(width:height:))

Center the preview in a fixed size container with the given dimensions.

[`fixedLayout(width:height:depth:)`](/documentation/DeveloperToolsSupport/PreviewTrait/fixedLayout(width:height:depth:))

Centers the preview in a fixed-size, 3D container.

[`sizeThatFitsLayout`](/documentation/DeveloperToolsSupport/PreviewTrait/sizeThatFitsLayout)

Fit the container to the size of the preview when offered the size of
the device that the preview is running on.

### Getting an orientation

[`portrait`](/documentation/DeveloperToolsSupport/PreviewTrait/portrait)

The device is in portrait mode, with the top of the device on top.

[`portraitUpsideDown`](/documentation/DeveloperToolsSupport/PreviewTrait/portraitUpsideDown)

The device is in portrait mode, but is upside down.

[`landscapeLeft`](/documentation/DeveloperToolsSupport/PreviewTrait/landscapeLeft)

The device is in landscape mode, with the top of the device on the left.

[`landscapeRight`](/documentation/DeveloperToolsSupport/PreviewTrait/landscapeRight)

The device is in landscape mode, with the top of the device on the right.



---

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)