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.
aria-requiredboolean—Announces the input as required to assistive technology without showing the Required marker, for fields whose requirement is already obvious. isRequired implies it.
autoCompletestring—HTML autocomplete hint for the browser.
classNamestring—Additional CSS class names applied to the field root, or to the input wrapper when the input is inside an InputGroup.
data-testidstring—Test ID applied to the input element.
descriptionReactNode—Supporting text rendered below the label.
endContentReactNode—Content 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.
htmlNamestring—HTML 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*string—Field label.
labelEndReactNode—Content shown at the end of the label row, such as a link. It renders outside the label, so it does not focus the control or change its accessible name. It stays visible when isLabelHidden is true.
labelIconIconComponent—Icon shown before the label.
labelTooltipReactNode—Tooltip shown beside the label.
onBlur(event: FocusEvent<HTMLInputElement>) => void—Called when the input loses focus.
onChange*( value: string, event: ChangeEvent<HTMLInputElement> | null, ) => void—Called with the next string value.
onEnter() => void—Called when Enter is pressed.
onFocus(event: FocusEvent<HTMLInputElement>) => void—Called when the input gains focus.
onKeyDown(event: KeyboardEvent<HTMLInputElement>) => void—Keyboard event handler for the input.
placeholderstring—Placeholder text.
refRef<HTMLInputElement>—Ref forwarded to the input element.
roleAriaRole—ARIA role applied to the input element.
size"sm" | "md" | "lg"—Visual size.
startIconIconComponent—Icon shown before the input.
statusInputStatus—Status displayed on the field.
styleCSSProperties—Inline 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*string—Controlled 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.
aria-requiredboolean—Announces the input as required to assistive technology without showing the Required marker, for fields whose requirement is already obvious. isRequired implies it.
autoCompletestring—HTML autocomplete hint for the browser.
classNamestring—Additional CSS class names applied to the field root, or to the input wrapper when the input is inside an InputGroup.
data-testidstring—Test ID applied to the input element.
descriptionReactNode—Supporting text rendered below the label.
endContentReactNode—Content 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.
htmlNamestring—HTML 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*string—Field label.
labelEndReactNode—Content shown at the end of the label row, such as a link. It renders outside the label, so it does not focus the control or change its accessible name. It stays visible when isLabelHidden is true.
labelIconIconComponent—Icon shown before the label.
labelTooltipReactNode—Tooltip shown beside the label.
onBlur(event: FocusEvent<HTMLInputElement>) => void—Called when the input loses focus.
onChange*( value: string, event: ChangeEvent<HTMLInputElement> | null, ) => void—Called with the next string value.
onEnter() => void—Called when Enter is pressed.
onFocus(event: FocusEvent<HTMLInputElement>) => void—Called when the input gains focus.
onKeyDown(event: KeyboardEvent<HTMLInputElement>) => void—Keyboard event handler for the input.
placeholderstring—Placeholder text.
refRef<HTMLInputElement>—Ref forwarded to the input element.
roleAriaRole—ARIA role applied to the input element.
size"sm" | "md" | "lg"—Visual size.
startIconIconComponent—Icon shown before the input.
statusInputStatus—Status displayed on the field.
styleCSSProperties—Inline 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*string—Controlled 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.
aria-requiredboolean—Announces the input as required to assistive technology without showing the Required marker, for fields whose requirement is already obvious. isRequired implies it.
autoCompletestring—HTML autocomplete hint for the browser.
classNamestring—Additional CSS class names applied to the field root, or to the input wrapper when the input is inside an InputGroup.
data-testidstring—Test ID applied to the input element.
descriptionReactNode—Supporting text rendered below the label.
endContentReactNode—Content 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.
htmlNamestring—HTML 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*string—Field label.
labelEndReactNode—Content shown at the end of the label row, such as a link. It renders outside the label, so it does not focus the control or change its accessible name. It stays visible when isLabelHidden is true.
labelIconIconComponent—Icon shown before the label.
labelTooltipReactNode—Tooltip shown beside the label.
onBlur(event: FocusEvent<HTMLInputElement>) => void—Called when the input loses focus.
onChange*( value: string, event: ChangeEvent<HTMLInputElement> | null, ) => void—Called with the next string value.
onEnter() => void—Called when Enter is pressed.
onFocus(event: FocusEvent<HTMLInputElement>) => void—Called when the input gains focus.
onKeyDown(event: KeyboardEvent<HTMLInputElement>) => void—Keyboard event handler for the input.
placeholderstring—Placeholder text.
refRef<HTMLInputElement>—Ref forwarded to the input element.
roleAriaRole—ARIA role applied to the input element.
size"sm" | "md" | "lg"—Visual size.
startIconIconComponent—Icon shown before the input.
statusInputStatus—Status displayed on the field.
styleCSSProperties—Inline 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*string—Controlled input value.
isOptionalfalse—
isRequired*true—