For questions about Form - a component in Apple's SwiftUI framework that groups controls used for data entry, such as in settings or inspectors. When using this tag also include the more generic [swiftui] tag where possible.
Questions tagged [swiftui-form]
122 questions
69
votes
27 answers
How to create TextField that only accepts numbers
I'm new to SwiftUI and iOS, and I'm trying to create an input field that will only accept numbers.
TextField("Total number of people", text: $numOfPeople)
The TextField currently allows alphabetic characters, how do I make it so that the user can…

Lupyana Mbembati
- 1,516
- 2
- 14
- 19
14
votes
6 answers
SwiftUI: Padding inside TextField
I have a TextField in SwiftUI. When I apply padding to it as
TextField(text, text: $value)
.padding()
the padding is outside of the tap area of the TextField, i.e. tapping on the padding does not bring the text field into focus.
I would like to…

Vivek Roy
- 280
- 1
- 2
- 8
13
votes
2 answers
SwiftUI email validation
How is email validation done with swiftUI?
TextField("Please enter your e-mail", text: self.$email)
.modifier(ClearButton(text: $email))
.font(.headline)
.padding(10)
.foregroundColor(.black)
.background(Color.white)
…

user12723399
- 127
- 1
- 1
- 5
10
votes
2 answers
SwiftUI Form Picker only shows once
I am playing around with SwiftUI, and am currently building a Form using a Picker.
import SwiftUI
struct ContentView: View {
private let names = ["Bill", "Peter", "Johan", "Kevin"]
@State private var favoritePerson = "Bill"
var body: some…

Kevin Renskers
- 5,156
- 4
- 47
- 95
9
votes
0 answers
SwiftUI, iOS 14, Keyboard Avoidance in Form{ TextEditor() }
I am having a problem on a simple Form{}. Automatic Keyboard Avoidance is not working. Below is a small form with a TextEditor(). When run, the keyboard sits on top the input field, requiring the user to scroll the view so thay can enter a location.…

Kent
- 1,374
- 1
- 15
- 29
8
votes
1 answer
SwiftUI how to pass data to previous screen on dismiss
I want pass data on dismissing of presentViewController to previous screen. Here I would like to use block to pass data to previous screen as UIKitApp. But I'm not getting idea to pass data. What are the options we have to pass data to back?
struct…

Jessy
- 157
- 1
- 10
8
votes
2 answers
How to use material design text fields in SwiftUI
I want to use the Material Design text field component in SwiftUI. There is a Material Design Text Field Component written for UIKit but not one for SwiftUI. Is it possible to use this Material Design Text Field Component in SwiftUI?

David
- 91
- 5
7
votes
2 answers
SwiftUI - cells (inside Form) with clickable buttons
Goals:
Create a row/cell with buttons
Embed row/cell in a Form
What I did:
I created a cell, with buttons.
struct PointTypeButtons : View {
var body: some View {
VStack {
HStack {
…

Mane Manero
- 3,086
- 5
- 25
- 47
6
votes
1 answer
Swiftui Binding action tried to update multiple times per frame
I am having trouble debugging an issue with input from textfields.
Information:
-MacOs Monterey Version 12.0 Beta 21A5284e
-Xcode 13.0 beta 3 13A5192j
-Physical phone IOS 15.0 19A297e
Issue explanation:
When i try to type in a textfield that is…

Inb4cookies
- 165
- 2
- 9
6
votes
2 answers
SwiftUI DatePicker in Form Dismisses When Keyboard Appears
I have a SwiftUI Form with a Section that contains a DatePicker. The DatePicker is set to have a datePickerStyle of CompactDatePickerStyle(), by default, since it's in a Form.
When tapping on the DatePicker, the overlay is presented:
The…

Nick Kohrn
- 5,779
- 3
- 29
- 49
6
votes
2 answers
Form in SwiftUI, position the user picture like in the setting of IOS using swiftUI
How can I put the image in the Form of swiftUI in order to have the same effect like the picture attached?
I have try with this code, but not working:
struct UserDetails: View {
@ObservedObject var dm : DataManager
@Binding var userLoggato…

Damiano Miazzi
- 1,514
- 1
- 16
- 38
6
votes
1 answer
Reduce Form spacing between sections SwiftUI
I'm trying to make a notes app with SwiftUI and I'd like to show the notes similar to the Apollo Reddit app does.
The way it shows the post isn't anything special, it just shows the posts using an interface similar to a list with…

amodrono
- 1,900
- 4
- 24
- 45
6
votes
1 answer
SwiftUI Glitches in FormView
I am facing some weird glitches in my Form implementation. I am not sure whether this is some implementation error or a bug in SwiftUI itself.
So basically what I want to do is the typical "ToDo/TimeTracking" app. I want to create a new task entity…

grahan
- 2,148
- 5
- 29
- 43
6
votes
1 answer
Not possible to control animations in a Form?
Is it not meant to be possible to control the animations that take place inside of a Form view? I have here a playground that demonstrates the issue, along with a gif of what happens. As you can see, my transition on the 2nd animated view is…

bkocik
- 414
- 2
- 5
- 14
5
votes
3 answers
Spacer not working with Form inside a VStack
I'm trying to get a circle on top with the form content down below, right above my TabBar. I can somewhat force this by using .frame() but I'm not a big fan of that. It seems like there should be a simpler way in order to align it to the bottom.
My…

Joe Scotto
- 10,936
- 14
- 66
- 136