SwiftUI Form
Published Jan 31, 2023
Contribute to Docs
The Form view displays collected data in a single column. It is the main element used inside the settings application on Apple devices or “System Settings” on other devices.
Syntax
var body: some View {
Form {
Subviews here
}
}
Example
In the example below, a Form is wrapped inside a NavigationView that will display four fields:
@State private var email = ""var body: some View {NavigationView {Form {Text("This is a text")TextField("This is a textfield", text: $email)Button("This is a button") { }NavigationLink("This is a navigation link", destination:EmptyView())}}}
NavigationViewis a container that’s fundamental to the display, and allowsNavigationLinkto properly work.- Text is a built-in view that display standard text.
- The
TextFieldview allows the user to insert contact information, type memos, and edit the content of a specific field. - The Button view allows users to interact with the UI and perform certain actions.
- The
NavigationLinkview controls how the navigation between views is displayed to the user.
This will display the following:

Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn SwiftUI on Codecademy
- Learn how to build iOS applications with Swift and SwiftUI and publish them to Apples' App Store.
- Includes 7 Courses
- With Certificate
- Beginner Friendly.13 hours
- A powerful programming language developed by Apple for iOS, macOS, and more.
- Beginner Friendly.12 hours