---
title: "scrollTargetLayout(isEnabled:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/view/scrolltargetlayout(isenabled:)"
---

# scrollTargetLayout(isEnabled:)

Configures the outermost layout as a scroll target layout.

## Declaration

```swift
nonisolated func scrollTargetLayout(isEnabled: Bool = true) -> some View

```

## Discussion

Discussion This modifier works together with the ViewAlignedScrollTargetBehavior to ensure that scroll views align to view based content. Apply this modifier to layout containers like LazyHStack or VStack within a ScrollView that contain the main repeating content of your ScrollView. ScrollView(.horizontal) {     LazyHStack(spacing: 10.0) {         ForEach(items) { item in             ItemView(item)         }     }     .scrollTargetLayout() } .scrollTargetBehavior(.viewAligned) Scroll target layouts act as a convenience for applying a View/scrollTarget(isEnabled:) modifier to each views in the layout. A scroll target layout will ensure that any target layout nested within the primary one will not also become a scroll target layout. LazyHStack { // a scroll target layout     VStack { ... } // not a scroll target layout     LazyHStack { ... } // also not a scroll target layout } .scrollTargetLayout()

## See Also

### Defining scroll targets

- [scrollTargetBehavior(_:)](swiftui/view/scrolltargetbehavior(_:).md)
- [ScrollTarget](swiftui/scrolltarget.md)
- [ScrollTargetBehavior](swiftui/scrolltargetbehavior.md)
- [ScrollTargetBehaviorContext](swiftui/scrolltargetbehaviorcontext.md)
- [PagingScrollTargetBehavior](swiftui/pagingscrolltargetbehavior.md)
- [ViewAlignedScrollTargetBehavior](swiftui/viewalignedscrolltargetbehavior.md)
- [AnyScrollTargetBehavior](swiftui/anyscrolltargetbehavior.md)
- [ScrollTargetBehaviorProperties](swiftui/scrolltargetbehaviorproperties.md)
- [ScrollTargetBehaviorPropertiesContext](swiftui/scrolltargetbehaviorpropertiescontext.md)
