<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/modifier(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE8modifieryAA15ModifiedContentVyxqd__Gqd__lF"
  },
  "title" : "modifier(_:)"
}
-->

# modifier(_:)

Applies a modifier to a view and returns a new view.

```
nonisolated func modifier<T>(_ modifier: T) -> ModifiedContent<Self, T>
```

## Parameters

`modifier`

The modifier to apply to this view.

## Discussion

Use this modifier to combine a [`View`](/documentation/SwiftUI/View) and a [`ViewModifier`](/documentation/SwiftUI/ViewModifier), to
create a new view. For example, if you create a view modifier for
a new kind of caption with blue text surrounded by a rounded rectangle:

```
struct BorderedCaption: ViewModifier {
    func body(content: Content) -> some View {
        content
            .font(.caption2)
            .padding(10)
            .overlay(
                RoundedRectangle(cornerRadius: 15)
                    .stroke(lineWidth: 1)
            )
            .foregroundColor(Color.blue)
    }
}
```

You can use [`modifier(_:)`](/documentation/SwiftUI/View/modifier(_:)) to extend [`View`](/documentation/SwiftUI/View) to create new modifier
for applying the `BorderedCaption` defined above:

```
extension View {
    func borderedCaption() -> some View {
        modifier(BorderedCaption())
    }
}
```

Then you can apply the bordered caption to any view:

```
Image(systemName: "bus")
    .resizable()
    .frame(width:50, height:50)
Text("Downtown Bus")
    .borderedCaption()
```

![A screenshot showing the image of a bus with a caption reading](images/com.apple.SwiftUI/SwiftUI-View-ViewModifier@2x.png)

---

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)