Text Input

A component that displays a multi-line text input form.

Preview

Button Preview

Code Example

let model = TextInputVM {
  $0.placeholder = "Input any text here..."
  $0.minRows = 3
  $0.maxRows = 7
  $0.autocapitalization = .never
  $0.isAutocorrectionEnabled = false
}

API

TextInputVM Props

A model that defines the appearance properties for a text input component.

NameTypeDefaultDescription
autocapitalizationTextAutocapitalizationsentencesThe autocapitalization behavior for the text input.
colorComponentColor?nilThe color of the text input.
cornerRadiusComponentRadiusmediumThe corner radius of the text input.
fontUniversalFont?nilThe font used for the text input's text. Determined by size if not set.
isAutocorrectionEnabledBooltrueA Boolean value indicating whether autocorrection is enabled.
isEnabledBooltrueA Boolean value indicating whether the text input is enabled or disabled.
keyboardTypeUIKeyboardTypedefaultThe type of keyboard to display when the text input is active.
maxRowsInt?nilThe maximum number of rows the text input can expand to.
minRowsInt2The minimum number of rows the text input can occupy.
placeholderString?nilThe placeholder text displayed when there is no input.
sizeComponentSizemediumThe predefined size of the text input.
submitTypeSubmitTypereturnThe type of the submit button on the keyboard.
tintColorUniversalColoraccentThe tint color applied to the text input's cursor.

SUTextInput

public init(
  text: Binding<String>,
  globalFocus: FocusState<FocusValue>.Binding,
  localFocus: FocusValue,
  model: TextInputVM = .init()
)
public init(
  text: Binding<String>,
  isFocused: FocusState<Bool>.Binding,
  model: TextInputVM = .init()
)

UKTextInput

Initializers

public init(
  initialText: String = "",
  model: TextInputVM = .init(),
  onValueChange: @escaping (String) -> Void = { _ in }
)

Public Properties

NameTypeDescription
onValueChange(String) -> VoidA closure that is triggered when the text changes.
modelTextInputVMA model that defines the appearance properties.
textStringA text inputted in the field.

Public Subviews

NameTypeDescription
textViewUITextViewAn underlying text view instance from the standard library.
placeholderLabelUILabelA label used to display placeholder text when the inputted text is empty.