Edit page


TextField allows users to input text information.

Basic Usage

To implement the TextField component, you need to import it first:

import { TextField } from '@react-ui-org/react-ui';

And use it:

See API for all available options.

General Guidelines

  • Use the most suitable input type for current context: aside from the common text type, there are also email, number, password, and tel types at your disposal. A properly chosen input type is especially important for touch users as it triggers an appropriate virtual keyboard, so it helps speed up the completion of the field.

  • Beware of the number input type: it may not be always what you want. Not all number-like values are actually numbers, e.g. phone numbers, credit card numbers, or business IDs. In such cases use the most appropriate input type (probably text or tel) along with the pattern attribute to improve the input experience for touch users.

  • Use short and descriptive labels, ideally nouns rather than seemingly polite phrases like Please enter your first name. Short labels will help your users accomplish their task faster.

  • Only make the TextField's label invisible when there is another visual clue to guide users through filling the input.

  • When a short label is not enough, use help texts to guide users before they enter anything.

  • Optionally you can pre-fill your text fields with a placeholder to give users an example of what they're expected to fill in. Just remember the placeholder disappears once a value is entered so don't put anything important there. Usually, en example value starting with “Eg.” works best.

  • Use clear, calm error messages when there's a problem with what they entered. Be positive and focus on solutions to make the error message helpful.

  • When asking users for their contact information or other personal information, make use of the autocomplete attribute to help them fill the form faster.

Design Variants

To satisfy the design requirements of your project, all input fields in React UI come in two design variants to choose from: outline and filled. Both can be further customized with CSS custom properties.


Aside from the default (medium) size, two additional sizes are available: small and large.

Full-width fields span the full width of a parent:

Input Types

Aside from the common text type, there are also email, number, password, and tel types at your disposal.

Input Size

The default width of all inputs is 240 px, and it can be customized with a CSS custom property. However, you can also change the width of individual text fields using the inputSize property. It (obviously) sets the size attribute of the input element and is further picked up by CSS to normalize rendering across browsers.

👉 Remember that the size and max HTML attributes don't limit on how many characters the user can enter. Use the maxlength attribute to achieve that effect (doesn't work for number input type though).

👉 Note that according to the HTML specification, the size attribute (invoked by inputSize API option) is not available for number input type. TextField supports inputSize option for all types of inputs, so you can use it whenever you find it suitable. Just keep in mind the size attribute will not be present in the DOM for numeric inputs.

Invisible Label

In some cases, it may be convenient to visually hide the field label. The label remains accessible to assistive technologies.

While it may be acceptable for login screens with just a few fields or for other simple forms, it's dangerous to hide labels from users in most cases. Keep in mind you should provide another visual clue so users know what to fill into the input.

Horizontal Layout

The default vertical layout is very easy to use and work with. However, there are situations where horizontal layout suits better — and that's why React UI supports this kind of layout as well.

Help Text

You may provide an additional help text to clarify how the input should be filled.

Keep in mind that long help texts don't play well with small input sizes, especially in vertical layout. To fix this at least for horizontal layout, help text expands over the full field width when the desired input width (based on inputSize option) is 10 characters or smaller.


Validation States

Validation states visually present the result of validation of the input. You should always provide a validation message for states other than valid so users know what happened and what action they should take or what options they have.

Disabled State

It's possible to disable the whole input.

Forwarding HTML Attributes

In addition to the options below in the component's API section, you can specify React synthetic events or you can add whatever HTML attribute you like. All attributes that don't interfere with the API are forwarded to the native HTML <input>. This enables making the component interactive and helps to improve its accessibility.

👉 Refer to the MDN reference for the full list of supported attributes of the text, email, number, tel, and password input types.

Forwarding ref

If you provide ref, it is forwarded to the native HTML <input> element.


Prop nameTypeDefaultRequiredDescription

If true, the input will be disabled.


If true, the field will span the full width of its parent.


Optional help text.


ID of the input HTML element. It also serves as a prefix for nested elements:

  • <ID>__label
  • <ID>__labelText
  • <ID>__helpText
  • <ID>__validationText

Width of the input field. Translated as size attribute for input types other than number.


If false, the label will be visually hidden (but remains accessible by assistive technologies).


Text field label.

layout'horizontal' │ 'vertical''vertical'false

Layout of the field.

Ignored if the component is rendered within FormLayout component as the value is inherited in such case.


If true, the input will be required.

size'small' │ 'medium' │ 'large''medium'false

Size of the field.

type'email' │ 'number' │ 'password' │ 'tel' │ 'text''text'false

HTML input type, translated as type attribute of the input.

validationState'invalid' │ 'valid' │ 'warning'nullfalse

Alter the field to provide feedback based on validation result.


Validation message to be displayed.

variant'filled' │ 'outline''outline'false

Design variant of the field, further customizable with CSS custom properties.


Head to Forms Theming to see shared form theming options.