Add explanation/description text below a setting in SwiftUI

Viewed 33

In SwiftUI, what is the standard way (or the recommended way) to add "explanation" text to a setting. For example, in the screen shot below of the system Maps app's settings, the Speed Limit toggle has the following explanation text beneath it:

Speed limit information will be shown when available.

settings screen shot

1 Answers

If you want something like the image you posted try Form. It can contain multiple Section where you can provide a header and a footer View.

documentation

Example:

struct TestView: View{
    var body: some View{
        Form{
            Section {
                Text("content")
            } header: {
                Text("header")
            } footer: {
                Text("footer")
            }
        }

    }
}

exmaple

Related