UI.TextField is an accessible and customizable interface for text inputs.
Indicating the type of input data unlocks specific features like mobile's autocompleting, browser's spell-checking, and password-related.
Different from Element.Input, style is pre-applied following the design documents, and not customizable.
TextField.email Msg.OnTextFieldChanged
"Enter your email"
model.emailValue
|> TextField.setLabelVisible True
|> TextField.renderElement renderConfigNotes:
Every input must have a label value, even if hidden, for accessibility purposes.
Username, email, current password, and search activates in-browser autocomplete capabilities.
Username and email content-types may have the same use case scenario (e.g., login, sign up), but the email has an in-browser mask checking.
Wrapper around Element.Input.text .
TextField.singlelineText Msg.OnTextFieldChanged
"My cool input"
model.valueWrapper around Element.Input.multiline .
TextField.multiline Msg.OnTextFieldChanged
"My cool textarea"
model.valueWrapper around Element.Input.spellChecked .
TextField.spellChecked Msg.OnTextFieldChanged
"Spell checking"
model.valueWrapper around Element.Input.newPassword .
TextField.newPassword Msg.OnTextFieldChanged
"New password"
model.valueWrapper around Element.Input.currentPassword .
TextField.currentPassword Msg.OnTextFieldChanged
"Current password"
model.valueMake the password on newPassword and currentPassword visible to the user.
TextField.setPasswordVisible True someTextFieldWrapper around Element.Input.username .
TextField.username Msg.OnTextFieldChanged
"Username"
model.valueWrapper around Element.Input.email .
TextField.email Msg.OnTextFieldChanged
"Email"
model.value
|> TextField.setLabelVisible TrueWrapper around Element.Input.search .
TextField.search Msg.OnTextFieldChanged
"Search something"
model.valueSimulate a TextField.singlelineText visually, but the content isn't changeable.
TextField.static
"Not changeable"
"Any constant value"With TextField.withSize, you'll be able to scale the field between the standard sizes.
The sizes (in height) are: Large - 60px; Medium - 48px; Small - 36px; Extra Small - 28px.
TextField.withSize Size.large someFieldNOTE: TextField's default size is Size.medium
Describes a compatible width.
TextField.withWidth changes the width of the field.
TextField.withWidth TextField.widthFull someTextFieldThe field's width will fill its container.
The field will have the exact width to fit its contents.
NOTE: Default behaviour.
Show or hide the text field's label.
TextField.setLabelVisible True someTextFieldPlace-holds the text field with text.
TextField.withPlaceholder "Enter your personal email" someTextFieldAppend an icon to the end of the text field.
TextField.search Msg.OnTextFieldChanged
"Search something"
model.value
|> TextField.withIcon
(Icon.search "Search")NOTE: Not ready.
Listen to focus events, add tab-indexing and enforce focus state.
TextField.withFocus
{ onEnter = Msg.FocusOnThisField
, tabIndex = 1
, hasFocus = True
}
someTextFieldTrigger message when the users press return-key while editing the text field.
TextField.withOnEnterPressed Msg.SubmitField someTextFieldReplaces the text with an error message and make the border red.
TextField.withError "Minimum eight caracters." someTextFieldEnd of the builder's life. The result of this function is a ready-to-insert Elm UI's Element.
The
TextField msgtype is used for describing the component for later rendering.