Start sharing components as a team!Share components as a team!Join Bit to build your applications faster.Get Started Free

text-field

v3.9.2arrow_drop_down
v3.9.2
STATUS
Passing
DOWNLOADS
856
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
6 months ago
SIZE
46 KB
subject
The `TextField` is a convenience wrapper for the most common cases (80%)
1 contributor
Use text-field in your project ?
Copied
npm i @bit/mui-org.material-ui.text-field
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.dev
Component Example
React
React
Vue
Angular
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
revert changes
reload
toggle layout
maximize
modifieddraft
modifieddraft
modifieddraft
modifieddraft
modifieddraft
modifieddraft
modifieddraft
modifieddraft
modifieddraft
modifieddraft
chevron_left
chevron_right
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 native input, 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
Properties
NameTypeDefault valueDescription
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 here: https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill

autoFocus
bool

If true, the input will be focused during the first mount.

children
node
className
string
defaultValue
string | number

The default value of the Input element.

disabled
bool

If true, the input will be disabled.

error
bool

If true, the label will be displayed in an error state.

FormHelperTextProps
object

Properties applied to the FormHelperText element.

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 input element. Use this property to make label and helperText accessible for screen readers.

InputLabelProps
object

Properties applied to the InputLabel element.

InputProps
object

Properties applied to the Input element.

inputProps
object

Attributes applied to the native input element.

inputRef
function | object

Use this property to pass a ref callback to the native input component.

label
node

The label content.

margin
'none' | 'dense' | 'normal'

If dense or normal, 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 input element.

onBlur
function
onChange
function

The event source of the callback. You can pull out the new value by accessing event.target.value.

onFocus
function
placeholder
string

The short hint displayed in the input before the user enters a value.

required
boolfalse

If true, the label is displayed as required and the input will be required.

rows
string | number

Number of rows to display when multiline option is set to true.

rowsMax
string | number

Maximum number of rows to display when multiline option is set to true.

select
boolfalse

Render a Select element while passing the Input element to Select as input parameter. If this option is set you must pass the options of the select as children.

SelectProps
object

Properties applied to the Select element.

type
string

Type attribute of the Input element. It should be a valid HTML5 input type.

value
string | number | bool | string | number | bool[]

The value of the Input element, required for a controlled component.

variant
'standard' | 'outlined' | 'filled''standard'

The variant to use.