Edit page

TextField

Labels for TextFields should describe what the field is. Labels should not be followed by a colon. Placeholder text should describe the specifics about formatting or examples for the input text. Placeholder text is optional, and should never be used to replace a label.

Required TextFields should have the required attribute. Optional TextFields should be clearly marked with "(optional)".

Try not to include too many optional fields, as it will make the form harder to comprehend and complete for the user.

Import Syntax

Basic Usage

Advanced Usage

placeholder
value
Needs to be .gov
error
That's a number!
success
search
fullWidth
type="textarea"
$
with adornments

With Label

htmlFor & id
auto generated id

Minimal

$
with adornments

With a Ref

with Formik

{
  "name": "",
  "email": "",
  "password": ""
}

Props

PropertyTypeRequiredDefaultDescription
typeEnumfalsetextHTML prop to be applied to the input
valueNodefalse-HTML prop for the current value of the input
errorBoolfalse-The form control should show an error
successBoolfalse-The form control should show success
searchBoolfalse-Option to display a magnifying glass icon and clear button to the input.
onRequestClearFuncfalse-Callback when Search clear button is clicked
fullWidthBoolfalse-Make the TextField 100% width
minimalBoolfalse-Display prop to style the TextField with a simplified UI
horizontalBoolfalse-TextField and label should appear side by side instead of stacked
idStringfalse-HTML prop for the TextField, works together with a label's `for` prop
nameStringfalse-HTML prop to name the form element