How To Create SwiftUI Forms With Pickers

How To Create SwiftUI Forms With Pickers: A Beginner’s Guide

When working with SwiftUI, the Picker is one of the most versatile and frequently used components for selecting values from a list. Whether it’s choosing from a set of categories, selecting a date, or toggling between options, Pickers give users a clean, native interface for input. But building a Picker isn’t just about displaying options—it’s about making the app respond to the user’s choice. 

That’s where attaching actions to the Picker becomes essential. In this blog, we’ll explore how to trigger actions when a selection changes in SwiftUI, covering best practices, code examples, and scenarios where Pickers can enhance both functionality and user experience.

What Is A SwiftUI Form?

SwiftUI Forms are container views specifically made to hold input controls and display them in a structured, easy-to-read manner – much like the ones you see in Settings apps of iOS.If you are learning how to design mobile app interface, using SwiftUI Forms can be a great starting point. By embedding TextFields, Toggles, Pickers, and Sliders within a Form, SwiftUI automatically styles them in ways that are optimized for the platform. Spacing and grouping are automatically handled, ensuring your UI remains consistent with native iOS design standards. This saves development time and provides a responsive, accessible, intuitive user experience without the need for complicated custom styling.

Step-by-Step Guide To Create A SwiftUI Form With Pickers

SwiftUI makes it simple to build clean, user-friendly forms with built-in elements like TextFields, Toggles, Buttons, and Pickers. Let’s walk through creating a Contact Form that includes a picker for selecting a subject.

Step 1: Create a New SwiftUI Project

Create a New SwiftUI Project
  1. Open Xcode → choose iOS → App.
  2. Name it Travel Feedback.
  3. Select:
    • Interface: SwiftUI
    • Life Cycle: SwiftUI App
    • Language: Swift
  4. Now you have a blank SwiftUI app.


Step 2: Add a Simple Form

Replace the default code with this:

 Run it. You’ll see a very simple form with one line of text.

Step 3: Let People Type Their Info

We’ll add boxes where the user can enter their name, email, and comments.

 Try typing in the fields. Notice how the text changes live; that’s because of @State.

Step 4: Group Inputs into Sections

Forms look cleaner when we separate info into parts.

 Now your form has headers like “Traveler Info” and “Your Feedback.”

Step 5: Add a Picker (Dropdown)

We’ll let the user choose their favorite destination from a list.

Run it. You’ll see a dropdown with city names.

Step 6: Make It Look Like an App

Wrapping the form in a NavigationView gives it a title bar.

 Now it looks like a proper iPhone app screen.

Step 7: Add a Rating with Buttons

We’ll ask users to rate their trip using a segmented control (buttons side by side).

 Now users can tap Poor / Average / Good / Excellent.

Step 8: Add a Submit Button

Finally, let’s add a button that shows the data in the console (you’ll see it in Xcode’s output).

Run it, fill the form, then press “Submit Feedback.”

 Final Result

You just built a Travel Feedback Form with:

Final Output: SwiftUI with Picker
  • Text fields for name & email
  • A text box for comments
  • A picker for destinations
  • Segmented buttons for rating
  • A submit button

Also Read: Technologies to Develop Mobile Apps

Conclusion

In conclusion, creating forms in SwiftUI is both simple and powerful, allowing you to capture inputs, organize sections, and enhance usability with pickers and custom controls. By following this beginner-friendly walkthrough, you’ve seen how even a small project can bring together essential elements of interactivity and design. Whether you’re building a feedback form, a survey, or a registration page, this guide to making a SwiftUI form with pickers equips you with the foundation to expand and customize your app ideas with confidence.

Advait Upadhyay

Advait Upadhyay (Co-Founder & Managing Director)

Advait Upadhyay is the co-founder of Talentelgia Technologies and brings years of real-world experience to the table. As a tech enthusiast, he’s always exploring the emerging landscape of technology and loves to share his insights through his blog posts. Advait enjoys writing because he wants to help business owners and companies create apps that are easy to use and meet their needs. He’s dedicated to looking for new ways to improve, which keeps his team motivated and helps make sure that clients see them as their go-to partner for custom web and mobile software development. Advait believes strongly in working together as one united team to achieve common goals, a philosophy that has helped build Talentelgia Technologies into the company it is today.
View More About Advait Upadhyay
India

Dibon Building, Ground Floor, Plot No ITC-2, Sector 67 Mohali, Punjab (160062)

Business: +91-814-611-1801
USA

7110 Station House Rd Elkridge MD 21075

Business: +1-240-751-5525
Dubai

DDP, Building A1, IFZA Business Park - Dubai Silicon Oasis - Dubai - UAE

Business: +971 565-096-650
Australia

G01, 8 Merriville Road, Kellyville Ridge NSW 2155, Australia

call-icon