Skip to content

Text field - Frameworks

A text field is a single-line input component used for entering and editing textual data.

AndroidreleasedElementsreleasediOSreleasedReactreleasedVuereleased

iOS

Syntax

swift
Warp.TextField(
    title: String = "",
    additionalInformation: String? = nil,
    tooltipContent: AnyView? = nil,
    leftIcon: Warp.Icon? = nil,
    prefix: String? = nil,
    text: Binding<String>,
    placeholder: String = "",
    suffix: String? = nil,
    rightIcon: Warp.Icon? = nil,
    rightIconAction: @escaping () -> Void? = { nil },
    style: Warp.TextFieldStyle = .default,
    helpText: String? = nil
)

Visual options

There are a variety of variants supported for the TextField component:

swift
enum Warp.TextFieldStyle {
    case `default`
    case disabled
    case error
    case readOnly
}

Legacy support

By default all Warp components return a SwiftUI View but there is always a UIKit UIView available to use also.

swift
Warp.TextField(
    title: "Title",
    text: $text,
    placeholder: "Please fill me"
).uiView

Params

Required props

NameTypeDefaultDescription
textBinding StringBinding to the text content.

Optional props

NameTypeDefaultDescription
titleStringemptyThe main title text to display.
additionalInformationString?nilOptional text to display after the title.
tooltipContentAnyView?nilAn optional view to display when the tooltip icon is tapped.
leftIconWarp.Icon?nilAn optional Warp.Icon displayed on the left side of the text field.
prefixString?nilAn optional string displayed before the text input.
placeholderStringemptyText to display when the text field is empty.
suffixString?nilAn optional string displayed after the text input.
rightIconWarp.Icon?nilAn optional Warp.Icon displayed on the right side of the text field.
rightIconAction() -> Void?nilAn optional action for right icon
styleWarp.TextFieldStyle.defaultThe style of the text field. Use one of the predefined TextFieldStyle values: .default, .disabled, .error, or .readOnly
helpTextString?nilOptional String to display below the text field.

Questions?

Feel free to ask any questions on usage in the Warp DS Slack channel: #warp-design-system