title: Implementing a tag list in SwiftUI
body: <p>I am trying to implement a tag list in SwiftUI but I'm unsure how to get it to wrap the tags to additional lines if the list overflows horizontally.  I started with a string array called tags and within SwiftUI I loop through the array and create buttons as follows:</p>
  
  <pre><code>HStack{
      ForEach(tags, id: \.self){tag in
          Button(action: {}) {
              HStack {
                  Text(tag)
                  Image(systemName: "xmark.circle")
              }
          }
          .padding()
          .foregroundColor(.white)
          .background(Color.orange)
          .cornerRadius(.infinity)
          .lineLimit(1)
      }
  }
  </code></pre>
  
  <p>If the tags array is small it renders as follows:
  <a href="https://i.stack.imgur.com/8RqhD.png" rel="noreferrer"><img src="https://i.stack.imgur.com/8RqhD.png" alt="enter image description here"></a></p>
  
  <p>However, if the array has more values it does this:</p>
  
  <p><a href="https://i.stack.imgur.com/JprMk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/JprMk.png" alt="enter image description here"></a></p>
  
  <p>The behavior I am looking for is for the last tag (yellow) to wrap to the second line.  I realize it is in an HStack, I was hoping I could add a call to lineLimit with a value of greater than one but it doesn't seem to change the behavior.  If I change the outer HStack to a VStack, it puts each Button on a separate line, so still not quite the behavior I am trying create. Any guidance would be greatly appreciated.</p>