Labels in list provide consistent alignment hence improving visual appearance.
List without Label:
List {
Text("DevTechie Courses")
.font(.largeTitle)HStack {
Image(systemName: "person.circle")
Divider()
Text("SwiftUI 3")
}HStack {
Image(systemName: "envelope")
Divider()
Text("SwiftUI Deep Dive")
}HStack {
Image(systemName: "calendar.day.timeline.right")
Divider()
Text("SwiftUI Deep Dive")
}
}
Notice Divider, it's not aligned between rows.
Change HStack to Label:
List {
Text("DevTechie Courses")
.font(.largeTitle)Label {
Text("SwiftUI 3")
} icon: {
Image(systemName: "person.circle")
.foregroundColor(.primary)
}Label {
Text("SwiftUI Deep Dive")
} icon: {
Image(systemName: "envelope")
.foregroundColor(.primary)
}Label {
Text("SwiftUI 3 Deep Dive")
} icon: {
Image(systemName: "calendar.day.timeline.right")
.foregroundColor(.primary)
}}