Text input

Text inputs are used to capture textual information as well as numbers and passwords.

Backpack-SwiftUI/TextField

Cocoapods class reference view on Github

Day Night

Usage

Create a BPKTextField and bind the text property to a Binding<String>.


                                                
                                                @State var text: String = ""
                                                
                                                BPKTextField(text: $text)

Setting a placeholder


                                                
                                                BPKTextField("Placeholder", text: $text)

Changing the State


                                                
                                                BPKTextField(text: $text)
                                                    .inputState(.error)
                                                    .inputState(.valid)

Adding a clear button


                                                
                                                @State var text: String = "some text"
                                                
                                                BPKTextField(text: $text)
                                                    .inputState(
                                                        .clear(
                                                            accessibilityLabel: "Clear",
                                                            action: { text = "" }
                                                        )
                                                    )