---
title: PreviewLayout
framework: developertoolssupport
role: symbol
role_heading: Enumeration
path: developertoolssupport/previewlayout
---

# PreviewLayout

A size constraint for a preview.

## Declaration

```swift
enum PreviewLayout
```

## Overview

Overview Customize the layout of a preview that you define using the PreviewProvider protocol by providing one of the preview layout values to the previewLayout(_:) view modifier. For example, you can tell the preview to take up only the amount of space that the view requires with PreviewLayout.sizeThatFits: struct CircleImage_Previews: PreviewProvider {     static var previews: some View {         CircleImage()             .previewLayout(.sizeThatFits)     } } note: When you migrate away from preview providers and to preview macros, you specify layout using one of the PreviewTrait layout values with a macro that takes traits, like Preview(_:traits:_:body:).

## Topics

### Getting a layout

- [PreviewLayout.device](developertoolssupport/previewlayout/device.md)
- [PreviewLayout.fixed(width:height:)](developertoolssupport/previewlayout/fixed(width:height:).md)
- [PreviewLayout.fixed3D(width:height:depth:)](developertoolssupport/previewlayout/fixed3d(width:height:depth:).md)
- [PreviewLayout.sizeThatFits](developertoolssupport/previewlayout/sizethatfits.md)

## Relationships

### Conforms To

- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Preview definition

- [Preview](developertoolssupport/preview.md)
- [PreviewTrait](developertoolssupport/previewtrait.md)
- [PreviewRegistry](developertoolssupport/previewregistry.md)
