Skip to content

TextInput

Single-line text input field.

function ControlledTextInput({
isOptional,
isRequired,
value: initialValue = '',
...args
}: ControlledTextInputProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
return (
<TextInput
{...args}
{...getNecessity(isOptional, isRequired)}
onChange={setValue}
value={value}
/>
);
}
<ControlledTextInput {...args} />
function ControlledTextInput({
isOptional,
isRequired,
value: initialValue = '',
...args
}: ControlledTextInputProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
return (
<TextInput
{...args}
{...getNecessity(isOptional, isRequired)}
onChange={setValue}
value={value}
/>
);
}
<ControlledTextInput {...args} />
function ControlledTextInput({
isOptional,
isRequired,
value: initialValue = '',
...args
}: ControlledTextInputProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
return (
<TextInput
{...args}
{...getNecessity(isOptional, isRequired)}
onChange={setValue}
value={value}
/>
);
}
<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>
function ControlledTextInput({
isOptional,
isRequired,
value: initialValue = '',
...args
}: ControlledTextInputProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
return (
<TextInput
{...args}
{...getNecessity(isOptional, isRequired)}
onChange={setValue}
value={value}
/>
);
}
<ControlledTextInput {...args} />
function ControlledTextInput({
isOptional,
isRequired,
value: initialValue = '',
...args
}: ControlledTextInputProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
return (
<TextInput
{...args}
{...getNecessity(isOptional, isRequired)}
onChange={setValue}
value={value}
/>
);
}
<ControlledTextInput {...args} />
Enter your legal first and last name
function ControlledTextInput({
isOptional,
isRequired,
value: initialValue = '',
...args
}: ControlledTextInputProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
return (
<TextInput
{...args}
{...getNecessity(isOptional, isRequired)}
onChange={setValue}
value={value}
/>
);
}
<ControlledTextInput {...args} />
function ControlledTextInput({
isOptional,
isRequired,
value: initialValue = '',
...args
}: ControlledTextInputProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
return (
<TextInput
{...args}
{...getNecessity(isOptional, isRequired)}
onChange={setValue}
value={value}
/>
);
}
<ControlledTextInput {...args} />
function ControlledTextInput({
isOptional,
isRequired,
value: initialValue = '',
...args
}: ControlledTextInputProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
return (
<TextInput
{...args}
{...getNecessity(isOptional, isRequired)}
onChange={setValue}
value={value}
/>
);
}
<ControlledTextInput {...args} />
function ControlledTextInput({
isOptional,
isRequired,
value: initialValue = '',
...args
}: ControlledTextInputProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
return (
<TextInput
{...args}
{...getNecessity(isOptional, isRequired)}
onChange={setValue}
value={value}
/>
);
}
<ControlledTextInput {...args} />
function ControlledTextInput({
isOptional,
isRequired,
value: initialValue = '',
...args
}: ControlledTextInputProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
return (
<TextInput
{...args}
{...getNecessity(isOptional, isRequired)}
onChange={setValue}
value={value}
/>
);
}
<ControlledTextInput {...args} />
USD
function ControlledTextInput({
isOptional,
isRequired,
value: initialValue = '',
...args
}: ControlledTextInputProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
return (
<TextInput
{...args}
{...getNecessity(isOptional, isRequired)}
onChange={setValue}
value={value}
/>
);
}
<ControlledTextInput {...args} />
This name is already taken
Username is available
function ControlledTextInput({
isOptional,
isRequired,
value: initialValue = '',
...args
}: ControlledTextInputProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
return (
<TextInput
{...args}
{...getNecessity(isOptional, isRequired)}
onChange={setValue}
value={value}
/>
);
}
<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>
function ControlledTextInput({
isOptional,
isRequired,
value: initialValue = '',
...args
}: ControlledTextInputProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
return (
<TextInput
{...args}
{...getNecessity(isOptional, isRequired)}
onChange={setValue}
value={value}
/>
);
}
<ControlledTextInput {...args} />
For international numbers, include the country code.
function ControlledTextInput({
isOptional,
isRequired,
value: initialValue = '',
...args
}: ControlledTextInputProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
return (
<TextInput
{...args}
{...getNecessity(isOptional, isRequired)}
onChange={setValue}
value={value}
/>
);
}
<ControlledTextInput {...args} />
function ControlledTextInput({
isOptional,
isRequired,
value: initialValue = '',
...args
}: ControlledTextInputProps): React.JSX.Element {
const [value, setValue] = useState(initialValue);
return (
<TextInput
{...args}
{...getNecessity(isOptional, isRequired)}
onChange={setValue}
value={value}
/>
);
}
<ControlledTextInput {...args} />

Single-line text input field.

When isOptional: false, isRequired: false

PropTypeDefaultDescription
aria-activedescendantAriaAttributes['aria-activedescendant']Identifies the currently active element in a composite widget controlled by the input.
aria-autocompleteAriaAttributes['aria-autocomplete']Indicates whether typing displays completion suggestions.
aria-controlsAriaAttributes['aria-controls']Identifies the element controlled by the input.
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.
isReadOnlybooleanfalseWhether the value is displayed without allowing focus or interaction.
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.
roleAriaRoleARIA role applied 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" | "tel" | "email" | "password"HTML input type.
value*stringControlled input value.
isOptionalfalse
isRequiredfalse

When isOptional: true, isRequired: false

PropTypeDefaultDescription
aria-activedescendantAriaAttributes['aria-activedescendant']Identifies the currently active element in a composite widget controlled by the input.
aria-autocompleteAriaAttributes['aria-autocomplete']Indicates whether typing displays completion suggestions.
aria-controlsAriaAttributes['aria-controls']Identifies the element controlled by the input.
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.
isReadOnlybooleanfalseWhether the value is displayed without allowing focus or interaction.
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.
roleAriaRoleARIA role applied 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" | "tel" | "email" | "password"HTML input type.
value*stringControlled input value.
isOptional*true
isRequiredfalse

When isOptional: false, isRequired: true

PropTypeDefaultDescription
aria-activedescendantAriaAttributes['aria-activedescendant']Identifies the currently active element in a composite widget controlled by the input.
aria-autocompleteAriaAttributes['aria-autocomplete']Indicates whether typing displays completion suggestions.
aria-controlsAriaAttributes['aria-controls']Identifies the element controlled by the input.
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.
isReadOnlybooleanfalseWhether the value is displayed without allowing focus or interaction.
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.
roleAriaRoleARIA role applied 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" | "tel" | "email" | "password"HTML input type.
value*stringControlled input value.
isOptionalfalse
isRequired*true