<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "DeveloperToolsSupport",
  "identifier" : "/documentation/DeveloperToolsSupport/PreviewTrait/modifier(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "DeveloperToolsSupport"
    ],
    "preciseIdentifier" : "s:21DeveloperToolsSupport12PreviewTraitV7SwiftUIAA0D0V10ViewTraitsORszlE8modifieryACyAHGqd__AD0D8ModifierRd__lFZ"
  },
  "title" : "modifier(_:)"
}
-->

# modifier(_:)

Attach a `PreviewModifier` to the preview.

```
@MainActor static func modifier(_ modifier: some PreviewModifier) -> PreviewTrait<T>
```

## Discussion

You can compose modifiers by passing more than one instance of this
trait. Composed modifiers will be applied to the preview in order: the first
modifier will apply to the body of the preview, the second modifier to the
body of the first modifier, and so on.

---

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)