Get your own website
Demo.swift
ContentView.swift
App.swift
 
import SwiftUI

struct Product: Identifiable { let id: Int; let name: String; let price: Double }

struct ListCustomRowsDemo: View {
  let items = [
    Product(id: 1, name: "Coffee", price: 2.99),
    Product(id: 2, name: "Tea", price: 1.99)
  ]
  var body: some View {
    List {
      ForEach(items) { p in
        HStack { Text(p.name); Spacer(); Text(String(format: "$%.2f", p.price)) }
      }
    }
  }
}

                    
import SwiftUI

struct ContentView: View {
  var body: some View { ListCustomRowsDemo() }
}

                    
import SwiftUI

@main
struct MyApp: App {
  var body: some Scene { WindowGroup { ContentView() } }
}