<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-5HGSQD2L" height="0" width="0" style="display:none;visibility:hidden" title="GTM"></iframe>

Text Input

Input field for entering alpha-numerical information.

Use Text Input...

  • To input or edit freeform alpha-numerical information.
  • To input a single line of text.

Don't use Text Input...

The preview has been updated.

Type

Use an input type that is appropriate for the Text Input's function (e.g., type="email" for an email address field).

The preview has been updated.

Placeholder

Use placeholder to provide hints for what to enter.

Size

Mini

Use size="mini" to reduce the height of a Text Input.

The preview has been updated.

With Floating Label

  • Use TextInputWithFloatingLabel to create a label inside the input field that shifts position once the user starts entering text.
  • Note: the floating label looks like a placeholder text but it is not an HTML placeholder; any actual placeholder attribute on the input is transparent.

The preview has been updated.

With Button beside

Use TextInputWithButtonBeside to group a text input and button together.

The preview has been updated.

With icon-only Button inset

Use TextInputWithButtonInset to place an icon-only Button within the Text Input.

  • The typical use case is for search bars, and sign in forms.
  • You can also position the enclosed button either "left" or "right" by using the prop buttonPosition.

The preview has been updated.

Labels, Errors, and Helper Text

Refer to Form guidelines.

Managing State in React

Refer to Form guidelines.

Accessibility

Refer to the Accessibility guidelines for Form.

Implementation

  • Inputs default to a width of 100%, filling up their container; this is a best practice for responsive design.
  • To limit an input's width, you should constrain its container, e.g., by putting it into a Grid element of a certain number of columns.

Content


Where possible, assist the user with placeholder text to provide examples of what to enter.

Do

  • Keep label text succinct.

Don't

  • Use ellipsed text, as it will lead to incomplete information.

Props

TextInput
This component is implemented using the <input /> as the root element. You can utilize the native attributes supported by <input /> tag. The ref is directly assigned to the root element, allowing you to access and manipulate it as needed.
See core props for additional props that can be applied to this component.
proptyperequireddescriptiondefault
size"standard" | "mini" | nullfalse
⚠️ Deprecated - This is deprecated without a replacement.
The size variation Available options: 'standard', 'mini',
null
skin"standard" | "error" | nullfalse
The visual variant. Note that error is implied if the TextInput is used inside of a FormInput that also contains a FormError. Available options: 'standard', 'error'
standard
TextInputFloatingLabel
This component is implemented using the <label /> as the root element. You can utilize the native attributes supported by <label /> tag. The ref is directly assigned to the root element, allowing you to access and manipulate it as needed.
See core props for additional props that can be applied to this component.
TextInputWithFloatingLabel
This component is implemented using the <div /> as the root element. You can utilize the native attributes supported by <div /> tag. The ref is directly assigned to the root element, allowing you to access and manipulate it as needed.
See core props for additional props that can be applied to this component.
TextInputWithButtonBeside
This component is implemented using the <div /> as the root element. You can utilize the native attributes supported by <div /> tag. The ref is directly assigned to the root element, allowing you to access and manipulate it as needed.
See core props for additional props that can be applied to this component.
TextInputWithButtonInset
This component is implemented using the <div /> as the root element. You can utilize the native attributes supported by <div /> tag. The ref is directly assigned to the root element, allowing you to access and manipulate it as needed.
See core props for additional props that can be applied to this component.
proptyperequireddescriptiondefault
buttonPosition"left" | "right" | nullfalse
Position of the button. Available options: 'left', 'right'
null

Related

Was this page useful?

Thanks for your feedback!

Feel free to include your name if you wish to have a follow up conversation.


Published: Jan 7, 2022Last updated: Oct 17, 2024