YuryTom
YuryTom

Reputation: 75

SwiftUI LazyHGrid space between dynamic rows

Could you suggest how to have a dynamic number of rows in a grid. I have 5 words (these could be different width). The idea is to show them next to each other and if there is no enough space -> move to next row

I'm currently using this

var rows: [GridItem] = [.init(.adaptive(minimum: 60))]
LazyHGrid(rows: rows, spacing: 2)

but the space between rows is too big.

Any idea how to make it is smaller?

Thank you

This what I currently have This is what I'm trying to achieve

Upvotes: 5

Views: 2873

Answers (1)

Asperi
Asperi

Reputation: 257711

Add spacing in grid item

var rows: [GridItem] = [.init(.adaptive(minimum: 60), spacing: 2)]   

Upvotes: 7

Related Questions