When building scrollable screens in SwiftUI, List is not always the best choice for non-uniform data. Using ScrollView with lazy stacks and the Container View APIs introduced in recent SwiftUI versions, you can build custom reusable primitives that offer more design flexibility. The post walks through building ScrollingSurface (a ScrollView/LazyStack wrapper), DividedCard (using Group(subviews:) to insert dividers between child views), and SectionedSurface (using ForEach(sections:) to extract and filter sections). A custom NavigationButtonStyle replicates the chevron indicator normally provided by List. Together these primitives replicate List behavior while giving precise control over look and feel.

6m read timeFrom swiftwithmajid.com
Post cover image

Sort: