Displays a text field input with an optional slot for buttons and icons.
The Text Field component is made up of Root and Slot parts. View source.
Renders the text field input and accepts Slot parts.
This component is based on the input
element and supports common margin props m
, mx
, my
, ml
, mr
, mt
, mb
.
Contains icons or buttons associated with the text field, and provides the correct gap and padding according to the text field size.
You can compose up to two Slot parts – one on the left, and one on the right. The Slots provide a default gap and padding for its contents.
Use the size
prop to control the size of the input.
Use matching component sizes when composing Text Field with buttons. However, don’t use size 1 inputs with buttons – at this size, there is not enough vertical space to nest other interactive elements.
The state
prop is deprecated, as the types of state it represents may not be mutually exclusive. Use disabled
, readOnly
or invalid
instead.
The invalid
prop indicates that the field’s value is invalid. Fields are styled as valid
by default, though built-in client-side validation still applies. In a future version we may synchronize styled validation with the field’s internal validity state.