---
title: "transaction(_:body:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/view/transaction(_:body:)"
---

# transaction(_:body:)

Applies the given transaction mutation function to all animations used within the body closure.

## Declaration

```swift
nonisolated func transaction<V>(_ transform: @escaping (inout Transaction) -> Void, @ContentBuilder body: (PlaceholderContentView<Self>) -> V) -> some View where V : View

```

## Discussion

Discussion Any modifiers applied to the content of body will be applied to this view, and the changes to the transaction performed in the transform will only affect the modifiers defined in the body. The following code animates the opacity changing with a faster animation, while the contents of MyView are animated with the implicit transaction: MyView(isActive: isActive)     .transaction { transaction in         transaction.animation = transaction.animation?.speed(2)     } body: { content in         content.opacity(isActive ? 1.0 : 0.0)     } See Also: Transaction.disablesAnimations

## See Also

### Moving an animation to another view

- [withTransaction(_:_:)](swiftui/withtransaction(_:_:).md)
- [withTransaction(_:_:_:)](swiftui/withtransaction(_:_:_:).md)
- [transaction(_:)](swiftui/view/transaction(_:).md)
- [transaction(value:_:)](swiftui/view/transaction(value:_:).md)
- [Transaction](swiftui/transaction.md)
- [Entry()](swiftui/entry().md)
- [TransactionKey](swiftui/transactionkey.md)
