Skip to content

TextInput

Single-line text input field.

<ControlledTextInput {...args} />
<ControlledTextInput {...args} />
<div style={{display: 'flex', flexDirection: 'column', gap: 16}}>
<ControlledTextInput label="Small" placeholder="Small input" size="sm" />
<ControlledTextInput
label="Medium"
placeholder="Medium input"
size="md"
/>
<ControlledTextInput label="Large" placeholder="Large input" size="lg" />
</div>
<ControlledTextInput {...args} />
<ControlledTextInput {...args} />
Enter your legal first and last name
<ControlledTextInput {...args} />
<ControlledTextInput {...args} />
<ControlledTextInput {...args} />
<ControlledTextInput {...args} />
<ControlledTextInput {...args} />
USD
<ControlledTextInput {...args} />
This name is already taken
Username is available
<div style={{display: 'flex', flexDirection: 'column', gap: 16}}>
<ControlledTextInput
label="Error"
status={{message: 'This field is required', type: 'error'}}
value=""
/>
<ControlledTextInput
label="Warning"
status={{message: 'This name is already taken', type: 'warning'}}
value="admin"
/>
<ControlledTextInput
label="Success"
status={{message: 'Username is available', type: 'success'}}
value="ada_lovelace"
/>
</div>
<ControlledTextInput {...args} />

Single-line text input field.

When isOptional: false, isRequired: false

PropTypeDefaultDescription
autoCompletestringHTML autocomplete hint for the browser.
classNamestringAdditional CSS class names applied to the field root, or to the input wrapper when the input is inside an InputGroup.
data-testidstringTest ID applied to the input element.
descriptionReactNodeSupporting text rendered below the label.
endContentReactNodeContent rendered after the input, before the status icon.
hasAutoFocusbooleanfalseWhether to focus the input on mount.
hasClearbooleanfalseWhether to show a clear button when the input has a value.
htmlNamestringHTML name attribute.
isDisabledbooleanfalseWhether the input is disabled.
isLabelHiddenbooleanfalseWhether to visually hide the label.
isLoadingbooleanfalseWhether the input is loading.
label*stringField label.
labelIconIconComponentIcon shown before the label.
labelTooltipReactNodeTooltip shown beside the label.
onBlur(event: FocusEvent<HTMLInputElement>) => voidCalled when the input loses focus.
onChange*( value: string, event: ChangeEvent<HTMLInputElement> | null, ) => voidCalled with the next string value.
onEnter() => voidCalled when Enter is pressed.
onFocus(event: FocusEvent<HTMLInputElement>) => voidCalled when the input gains focus.
onKeyDown(event: KeyboardEvent<HTMLInputElement>) => voidKeyboard event handler for the input.
placeholderstringPlaceholder text.
refRef<HTMLInputElement>Ref forwarded to the input element.
size"sm" | "md" | "lg"Visual size.
startIconIconComponentIcon shown before the input.
statusInputStatusStatus displayed on the field.
styleCSSPropertiesInline styles applied to the field root, or to the input wrapper when the input is inside an InputGroup.
type"text" | "email" | "password"HTML input type.
value*stringControlled input value.
isOptionalfalse
isRequiredfalse

When isOptional: true, isRequired: false

PropTypeDefaultDescription
autoCompletestringHTML autocomplete hint for the browser.
classNamestringAdditional CSS class names applied to the field root, or to the input wrapper when the input is inside an InputGroup.
data-testidstringTest ID applied to the input element.
descriptionReactNodeSupporting text rendered below the label.
endContentReactNodeContent rendered after the input, before the status icon.
hasAutoFocusbooleanfalseWhether to focus the input on mount.
hasClearbooleanfalseWhether to show a clear button when the input has a value.
htmlNamestringHTML name attribute.
isDisabledbooleanfalseWhether the input is disabled.
isLabelHiddenbooleanfalseWhether to visually hide the label.
isLoadingbooleanfalseWhether the input is loading.
label*stringField label.
labelIconIconComponentIcon shown before the label.
labelTooltipReactNodeTooltip shown beside the label.
onBlur(event: FocusEvent<HTMLInputElement>) => voidCalled when the input loses focus.
onChange*( value: string, event: ChangeEvent<HTMLInputElement> | null, ) => voidCalled with the next string value.
onEnter() => voidCalled when Enter is pressed.
onFocus(event: FocusEvent<HTMLInputElement>) => voidCalled when the input gains focus.
onKeyDown(event: KeyboardEvent<HTMLInputElement>) => voidKeyboard event handler for the input.
placeholderstringPlaceholder text.
refRef<HTMLInputElement>Ref forwarded to the input element.
size"sm" | "md" | "lg"Visual size.
startIconIconComponentIcon shown before the input.
statusInputStatusStatus displayed on the field.
styleCSSPropertiesInline styles applied to the field root, or to the input wrapper when the input is inside an InputGroup.
type"text" | "email" | "password"HTML input type.
value*stringControlled input value.
isOptional*true
isRequiredfalse

When isOptional: false, isRequired: true

PropTypeDefaultDescription
autoCompletestringHTML autocomplete hint for the browser.
classNamestringAdditional CSS class names applied to the field root, or to the input wrapper when the input is inside an InputGroup.
data-testidstringTest ID applied to the input element.
descriptionReactNodeSupporting text rendered below the label.
endContentReactNodeContent rendered after the input, before the status icon.
hasAutoFocusbooleanfalseWhether to focus the input on mount.
hasClearbooleanfalseWhether to show a clear button when the input has a value.
htmlNamestringHTML name attribute.
isDisabledbooleanfalseWhether the input is disabled.
isLabelHiddenbooleanfalseWhether to visually hide the label.
isLoadingbooleanfalseWhether the input is loading.
label*stringField label.
labelIconIconComponentIcon shown before the label.
labelTooltipReactNodeTooltip shown beside the label.
onBlur(event: FocusEvent<HTMLInputElement>) => voidCalled when the input loses focus.
onChange*( value: string, event: ChangeEvent<HTMLInputElement> | null, ) => voidCalled with the next string value.
onEnter() => voidCalled when Enter is pressed.
onFocus(event: FocusEvent<HTMLInputElement>) => voidCalled when the input gains focus.
onKeyDown(event: KeyboardEvent<HTMLInputElement>) => voidKeyboard event handler for the input.
placeholderstringPlaceholder text.
refRef<HTMLInputElement>Ref forwarded to the input element.
size"sm" | "md" | "lg"Visual size.
startIconIconComponentIcon shown before the input.
statusInputStatusStatus displayed on the field.
styleCSSPropertiesInline styles applied to the field root, or to the input wrapper when the input is inside an InputGroup.
type"text" | "email" | "password"HTML input type.
value*stringControlled input value.
isOptionalfalse
isRequired*true