title: how to set the background color in a foreach loop in SwiftUI
body: <p>I have put the &quot;colour.green&quot; in every place within the code and I can't seem to work out how to make the background color of the foreach loop green.</p>
  <pre><code>struct DictionaryView: View {
      let sectionHeader: String
      let data: [tableContent]
      var body: some View {
          ZStack{
              Color.green
              VStack {
                  Section(header: Text(sectionHeader)) {
                  List{
                      ForEach(data, id: \.id) { value in
                          HStack {
                              
                              Text(value.label)
                                  .fontWeight(.light)
                                  .padding(.leading, 20.0)
                                  
                                  .frame(height: -10.0)
                              Spacer()
  
                              Text(String(value.data))
                                  .fontWeight(.light)
                                  .padding(.trailing, 20.0)
                                  .frame(height: -10.0)
                          }
                          
                      }
                  }
                          
              }
              }
          }
      }
  }
  </code></pre>
  <p>This is what I am getting:
  <a href="https://i.stack.imgur.com/roZbJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/roZbJ.png" alt="enter image description here" /></a></p>