Text Field
TextField lets people type a short value on a single line.
A TextField is a single-line text input. Use it for a name, an email address, a search query or any other short value. Use a TextArea when the value can run over several lines, a NumberField for a number with stepper buttons, and a Select or Combobox when the value comes from a fixed list.
leading and trailing place an icon, a unit or a button inside the field, before or after the text. The visible box is a wrapper around a native <input>, so className and style apply to the wrapper and a width sizes the whole field. ref points to the input, so .focus() and .select() work as usual.
Put a TextField inside a Field to give it a label, a description and an error message. The Field connects them to the input for screen readers and sets one size for the whole group. size uses the same steps as Button, so a field and the button beside it are the same height.
Set aria-invalid, or place the field in an invalid Field, to show an error border. disabled stops input and dims the field, while readOnly keeps the value selectable and sent with the form.
The input is a real <input>, so the keyboard, autofill, form submission and screen readers all work as they do for any native field. On a touch screen the text never drops below the size at which the browser zooms in when someone taps the field.
Props
Generated from the types. It lists what this component DECLARES: a prop that arrives from a shared type or from the platform is real and is not repeated here.
| Prop | Type | What it does |
|---|---|---|
backdrop? | boolean | Set backdrop when content passes behind the field. |
className? | string | Your classes, appended to the ones this component resolves rather than replacing them. |
leading? | React.ReactNode | Content before the text, such as an icon, a unit or a currency symbol. |
size? | "1" | "2" | "3" | "4" | Sets the size of the field: the height, the padding, the corner and the text. |
style? | React.CSSProperties | Inline styles, merged last, so your value wins over anything the component resolved. |
trailing? | React.ReactNode | Content after the text. |
type? | "text" | "email" | "password" | "search" | "tel" | "url" | "number" | The input type. |
It also takes every prop of a <input>.