# ScrollView

## Overview

Scrollview works Horizontally and Vertically. By default it works as Vertically.

```swift
ScrollView(.horizontal) {
HStack{}  // You should use relevant Stack HStack or LazyHStack
}

ScrollView(.vertical) {
VStack{}  // You should use relevant Stack VStack or LazyVStack
}
```

## Sample Codes

To use ScrollView across the screen you should expand it to the whole screen.

```swift
.frame(maxWidth: .infinity)
```

## Sources

### Videos

{% embed url="<https://youtu.be/l6Gj_goCWAY>" %}
[Hacking with Swift / 100 Days / Day-39 - How ScrollView lets us work with scrolling data](https://www.hackingwithswift.com/books/ios-swiftui/how-scrollview-lets-us-work-with-scrolling-data)
{% endembed %}

{% embed url="<https://youtu.be/KzbNpm4E3hs>" %}
[Hacking with Swift / 100 Days / Day-39 - How to lay out views in a scrolling grid](https://www.hackingwithswift.com/books/ios-swiftui/how-to-lay-out-views-in-a-scrolling-grid)
{% endembed %}

### Articles / Documents

* [Swift Dev Notes / Grids](https://swift.sedatonat.dev/view/page-elements/grid)
