---
title: "scrollToItem(at:at:animated:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uicollectionview/scrolltoitem(at:at:animated:)"
---

# scrollToItem(at:at:animated:)

Scrolls the collection view contents until the specified item is visible.

## Declaration

```swift
func scrollToItem(at indexPath: IndexPath, at scrollPosition: UICollectionView.ScrollPosition, animated: Bool)
```

## Parameters

- `indexPath`: The index path of the item to scroll into view.
- `scrollPosition`: An option that specifies where the item should be positioned when scrolling finishes. For a list of possible values, see doc://com.apple.uikit/documentation/UIKit/UICollectionView/ScrollPosition.
- `animated`: Specify doc://com.apple.documentation/documentation/Swift/true to animate the scrolling behavior or doc://com.apple.documentation/documentation/Swift/false to adjust the scroll view’s visible content immediately.

## See Also

### Scrolling an item into view

- [UICollectionView.ScrollPosition](uikit/uicollectionview/scrollposition.md)
- [UICollectionView.ScrollDirection](uikit/uicollectionview/scrolldirection.md)
