Sections 54: List Row Separators in SwiftUI

Customizing how a list is displayed has never been easier than with SwiftUI 3.0. Two new modifiers have been introduced to customize the list row separator's color and its visibility. Let's see how to use them!

 Customize list row separators.

Only on iOS 15 and higher

The new modifiers discussed in this tutorial are only supported in applications running on iOS 15.0 and higher. You'll need Xcode 13 and need to set your Xcode project's iOS target version to iOS 15.0 or higher, or wrap the code presented in this section in an if #available(iOS 15.0, *).

Create a list

Before learning how to use the new modifiers, we'll need to create an array we can iterate through first. We'll create a simple Author model with an id and a name, and right below, we'll create an array containing four authors.

struct Author: Identifiable {
    var id = UUID()
    var name: String

var authors = [Author(name: "Pranzo"), Author(name: "John Snow"), Author(name: "Emmi"), Author(name: "Selena")]


Let's call the authors array in our view and use it in our List. For each author, we'll display the name.

List(authors) {


List row separator tint

  • By default, the list row separator is grey. Starting iOS 15, we can now change its tint color with the new listRowSeparatorTint(_:edges:) modifier. 
  • The first argument is the color you wish to apply to the row separator. 
  • There's also an optional second argument: the edges on which the row separator tint color should be applied. By default, it's applied to all edges.



List row separator visibility

We can also add the listRowSeparator(_:edges:) modifier to each label in our List, to change the row separator's visibility. To hide the row separator, pass in the hidden argument. Hiding the row separator on some specific edges is also possible by passing a second argument. By default, the modifier is applied on all edges.



Popular posts from this blog

Sections 1: Visual Editor in SwiftUI

SwiftUI Overview

Learn with videos and source files. Available to "SwiftUI IO" subscribers only.