Skip to content
🚀 SwiftUI Grid : Autosizing layout based on minimum item width
Swift
Branch: master
Clone or download
Latest commit 86b5bed Aug 19, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Examples examples Aug 19, 2019
Resources examples Aug 19, 2019
Sources/Grid examples Aug 19, 2019
.gitignore gitignore Jul 31, 2019
LICENSE Create LICENSE Jul 31, 2019
Package.swift init Jul 29, 2019
README.md examples Aug 19, 2019

README.md

SwiftUI Grid

SwiftUI Grid view layout with auto-sizing items and flexible column count.

Examples

Open /Examples/GridExamples.xcodeproj for more examples for both iOS and macOS

/// Simple grid.

Grid(0...100, minimumItemWidth: 100) { _ in
    Rectangle()
        .foregroundColor(.red)
        .frame(height: 100)
}
/// Grid with minimum item width and fixed item height.

Grid(self.planets, minimumItemWidth: 320, spacing: 16) {
    PlanetView(planet: $0)
        .frame(height: 400)
        .onTapGesture {
            print("Selection:", $0)
        }
}

Performance

Requirements

  • Swift 5+
  • iOS 13+
  • macOS 10.15+

Roadmap

  • ZStack based grid instead of 'VStack of HStacks'
  • Support for watchOS
  • Items selection and rearranging
  • UITests
  • 'CSS Grid'-like features

Contibutions

Feel free to contribute via fork/pull request to master branch. If you want to request a feature or report a bug please start a new issue.

You can’t perform that action at this time.