TextField

TextField is used for user input. You would use it in forms when user input is required or for search. A TextField may be a single line or have multiple lines (textarea). Look into Forms for more on how to add labels and group inputs together.

For information on TextField/TextArea and Form style and usage guidelines, check out TextField Design Guidelines and Form Design Guidelines.

Example

A default TextField.

Text Areas

In order to have a multi-line text field, you must set it as a textarea. You can then define how many lines you would like the TextField to be.

Error State

You may provide styling for error state via the error prop - the border color will change and the respective icon will show on the right side. The TextField will not do any automatic text validation - you must manually trigger the error style. Look into Form on form validation. You may choose between default, error, warning, and success.

Other Styling

You may disable a TextField via the disabled prop. You could also add an svg icon without changing the error state via the icon prop.

Ref forwarding to input

Any ref to <TextField/> is fowarded to the actual input element. Hence you can do things like focus().

Common Props

TextField includes COMMON and COLOR common props. Read Common Props for details and API. These common props will override component props such as the color.

Prop nameTypeDefaultDescription
aria-labelStringthis should be set when the input's label is not visible on the screen
astextareadetermines if the input is multiline or not
autoCompleteStringHTML autocomplete attribute
disabledBooleanfalsedisable input
errordefault | error | warning | success'default'set the error state
iconReactNodenullset the icon component, displayed on the left of the input
idStringinput ID - this should be the same as a label's for prop
linesNumber3Number of lines a textarea should be - this should only be used when as=textarea
nameStringHTML name attribute
onChangeFunccallback to execute on user input
placeholderStringthe text to display in the input before typing
themeObjectBridge Themeuse to override default bridge theme
typeemail | number | password | tel | text | url | date'text'the type of content (for textarea, use as=textarea)
valueStringthe value of the content input