TextField API
The API documentation of the TextField React component. Learn more about the properties and the CSS customization points.
import TextField from '@material-ui/core/TextField';The TextField is a convenience wrapper for the most common cases (80%).
It cannot be all things to all people, otherwise the API would grow out of control.
Advanced Configuration
It's important to understand that the text field is a simple abstraction on top of the following components:
If you wish to alter the properties applied to the input element, you can do so as follows:
const inputProps = {
  step: 300,
};
return <TextField id="time" type="time" inputProps={inputProps} />;For advanced cases, please look at the source of TextField by clicking on the "Edit this page" button above. Consider either:
- using the upper case props for passing values directly to the components
- using the underlying components directly as shown in the demos
Props
| Name | Type | Default | Description | 
|---|---|---|---|
| autoComplete | string | This property helps users to fill forms faster, especially on mobile devices. The name can be confusing, as it's more like an autofill. You can learn more about it following the specification. | |
| autoFocus | bool | If true, theinputelement will be focused during the first mount. | |
| classes | object | Override or extend the styles applied to the component. See CSS API below for more details. | |
| defaultValue | any | The default value of the inputelement. | |
| disabled | bool | If true, theinputelement will be disabled. | |
| error | bool | If true, the label will be displayed in an error state. | |
| FormHelperTextProps | object | Properties applied to the FormHelperTextelement. | |
| fullWidth | bool | If true, the input will take up the full width of its container. | |
| helperText | node | The helper text content. | |
| id | string | The id of the inputelement. Use this property to makelabelandhelperTextaccessible for screen readers. | |
| InputLabelProps | object | Properties applied to the InputLabelelement. | |
| InputProps | object | Properties applied to the Input element. It will be a FilledInput,OutlinedInputorInputcomponent depending on thevariantprop value. | |
| inputProps | object | Attributes applied to the inputelement. | |
| inputRef | union: func | object | This property can be used to pass a ref callback to the inputelement. | |
| label | node | The label content. | |
| margin | enum: 'none' | 'dense' | 'normal' | If denseornormal, will adjust vertical spacing of this and contained components. | |
| multiline | bool | If true, a textarea element will be rendered instead of an input. | |
| name | string | Name attribute of the inputelement. | |
| onChange | func | Callback fired when the value is changed. Signature: function(event: object) => voidevent: The event source of the callback. You can pull out the new value by accessing event.target.value. | |
| placeholder | string | The short hint displayed in the input before the user enters a value. | |
| required | bool | false | If true, the label is displayed as required and theinputelement` will be required. | 
| rows | union: string | number | Number of rows to display when multiline option is set to true. | |
| rowsMax | union: string | number | Maximum number of rows to display when multiline option is set to true. | |
| select | bool | false | Render a Selectelement while passing the Input element toSelectasinputparameter. If this option is set you must pass the options of the select as children. | 
| SelectProps | object | Properties applied to the Selectelement. | |
| type | string | Type of the inputelement. It should be a valid HTML5 input type. | |
| value | any | The value of the inputelement, required for a controlled component. | |
| variant | enum: 'standard' | 'outlined' | 'filled' | 'standard' | The variant to use. | 
The ref is forwarded to the root element.
Any other properties supplied will be provided to the root element (FormControl).
Inheritance
The properties of the FormControl component are also available. You can take advantage of this behavior to target nested components.
Notes
The component is fully StrictMode compatible.