listSectionSeparator

Sets whether to hide the separator associated with a list section.

View ModifieriOS 15.0+macOS 13.0+listSectionSeparator(_:edges:) in SwiftUI

Declaration

React
compose().listSectionSeparator(
  visibility: SwiftUI.Visibility,
  options?: {
    edges?: SwiftUI.VerticalEdgeSet;
  }
)
Swift
nonisolated func listSectionSeparator(
    _ visibility: Visibility,
    edges: VerticalEdge.Set = .all
) -> some View

Parameters

Discussion

Separators can be presented above and below a section. You can specify to which edge this preference should apply.

This modifier expresses a preference to the containing List. The list style is the final arbiter of the separator visibility.

The following example shows a simple grouped list whose bottom sections separator are hidden:

List {
    ForEach(garage) { garage in
        Section(header: Text(garage.location)) {
            ForEach(garage.cars) { car in
                Text(car.model)
                    .listRowSeparatorTint(car.brandColor)
            }
        }
        .listSectionSeparator(.hidden, edges: .bottom)
    }
}
.listStyle(.grouped)

To change the visibility and tint color for a row separator, use View.listRowSeparator(_:edges:) and View.listRowSeparatorTint(_:edges:). To set the tint color for a section separator, use View.listSectionSeparatorTint(_:edges:).

See also

More in Lists and tables.