StandardTextField SwiftUI - admiral-team/admiralui-ios GitHub Wiki

Struct

An object that displays an editable text area in your interface.


Declaration

public struct StandardTextField<T>: TextFieldInput, AccessabilitySupportUIKit, Identifiable where T: View

Overview

Text fields allow users to type text into an app. They are used to build forms, send messages, create search experiences, and more. In this recipe, explore how to create and style text fields. Text field contains input text, placeholder, input text, helper text or error message, right icon. Text fields allow users to type text into an app. They are used to build forms, send messages, create search experiences, and more. In this recipe, explore how to create and style text fields. Text field contains input text, placeholder, input text, helper text or error message, right view.

Live example

Configure a StandardTextField

This example show how set text for input text, text for placeholder and text for helper text label.

StandardTextField(
     .constant("Text"),
     placeholder: "Placeholder",
     name: "Optional Label",
     state: .constant(.normal),
     info: .constant("Info")
)

Text field may be in four state.

Default

The normal state of the field in which the user can edit textfield

StandardTextField(
  state: .constant(.normal)
)

Read Only

The read only state disable user to modify textfield.

StandardTextField(
  state: .constant(.readOnly)
)

Error

The error state is useful to show the user an error.

StandardTextField(
  state: .constant(.error)
)

Disabled

The disabled state disable user input and hide input text.

StandardTextField(
  state: .constant(.disabled)
)

Configure right view

You have the option to set any view on right side text field. For example, you can set info button with icon in right view for describe text field.

StandardTextField(
  trailingView: {
     Image("")
  }
)

Contribution

You can help us to find bugs or ask us to add features.

  • To start issue please use ready-made templates.
  • To make changes to the repository, you need to create a fork of the project, make changes to the code and create a pull request in our project. You can read more about this in the Github documentation.