11

Is it possible to use LazyVGrid or LazyHGrid to get a view like this?

enter image description here

The Text values are rendered in the box, and if there is no more space near the right border, then it starts on the next row.

I have tried using the LazyGrids but it seems that since I am required to give a minimum column width

LazyVGrid(columns: [
   GridItem(.adaptive(minimum: 60)),
],

The text gets truncated. Is there any way to accomplish the view in the image above using grids?

Just a coder
  • 15,480
  • 16
  • 85
  • 138
  • 2
    Currently LazyH/VGrid support only *regular* structure, ie under any GridItem configuration they try to layout items with equal rows/columns, so your case is not possible to support now. – Asperi Aug 09 '20 at 12:34
  • You might find interesting [SwiftUI HStack with wrap and dynamic height](https://stackoverflow.com/a/62103264/12299030) – Asperi Aug 09 '20 at 12:35
  • @Asperi Thank you. Your answer here is what I am looking for. https://stackoverflow.com/questions/58842453/swiftui-hstack-with-wrap/58876712#58876712 – Just a coder Aug 09 '20 at 13:47
  • Does this answer your question? [SwiftUI HStack with Wrap](https://stackoverflow.com/questions/58842453/swiftui-hstack-with-wrap) – Senseful Jun 27 '23 at 14:45

0 Answers0