Skip to content

Input

Input is a text field: a one-line input, a password field or a multi-line textarea, in a bordered box that can also hold a prefix, a suffix, a clear button, a spinner and a character count. It sits on one line with a Button of the same size.

Demos

Basic

type="textarea" renders a multi-line field.

Size

tiny, small, medium (default) and large, the same heights as Button.

Round

round gives a text field a pill shape.

Prefix and suffix

prefix and suffix take any content: an icon, a currency, a unit.

Password

type="password" with showPasswordOn adds an eye button: click toggles the password, mousedown shows it only while the button is held.

Clearable

clearable adds a clear button that shows while the field has a value and is hovered or focused. It empties the field, calls onClear and keeps the focus in the field.

Autosize

autosize lets a textarea grow with its text: true starts at one row, { minRows, maxRows } bounds it and scrolls past maxRows. Without it, rows sets the height (default 3) and the textarea can be resized vertically.

Count

showCount shows the length, against maxLength when set. A textarea shows it under the text.

Status

status colors the border for validation: success, warning or error. Pair error with aria-invalid and a message the field points at with aria-describedby.

Loading

loading shows a spinner at the end. loading={false} keeps the spinner’s room, so the text doesn’t shift when loading starts.

Disabled and read-only

disabled blocks the field; readOnly keeps it focusable and selectable but not editable. Neither shows the clear button.

Controlled

Pass value and onUpdateValue to own the value. null means empty.

Native props and ref

Native attributes and events (id, name, autoComplete, role, aria-*, onKeyDown, …) go to the native input or textarea, and so does ref, so you can call focus() or select() on it. inputProps takes more of them; its type replaces the native type of a text field, e.g. email or search.

Input group

InputGroup joins Inputs, Buttons and InputGroupLabels into one row with shared borders.

Accessibility

Give every field a visible <label htmlFor> or an aria-label; id goes to the native element. The clear button is left out of the tab order (Select All and Delete do the same from the keyboard); the password toggle is a toggle button with aria-pressed, reachable by Tab when showPasswordOn="click". Their labels come from the ConfigProvider locale (Input.clear, Input.showPassword).

Props

Input

NameTypeDefaultDescriptionVersion
typetext | password | textareatextThe kind of field.Unreleased
valuestring | nullundefinedValue when controlled; null means empty.Unreleased
defaultValuestring | nullnullInitial value when uncontrolled.Unreleased
onUpdateValue(value: string) => voidundefinedCalled with the new value on every edit and on clear. Native onChange and onInput still get the event.Unreleased
sizetiny | small | medium | largemediumHeight, type size and padding, matching Button.Unreleased
placeholderstringundefinedNative placeholder.Unreleased
disabledbooleanfalseDisables the field.Unreleased
readOnlybooleanfalseFocusable and selectable, not editable.Unreleased
clearablebooleanfalseAdds a clear button while there is a value.Unreleased
onClear(event) => voidundefinedCalled after the clear button empties the field.Unreleased
statussuccess | warning | errorundefinedValidation status; colors the border.Unreleased
roundbooleanfalsePill shape. Ignored by textarea.Unreleased
prefixReactNodeundefinedContent before the text.Unreleased
suffixReactNodeundefinedContent after the text.Unreleased
loadingbooleanundefinedShows a spinner at the end; false keeps its room.Unreleased
showPasswordOnclick | mousedownundefinedWith type="password", adds a toggle that reveals the password.Unreleased
maxLengthnumberundefinedNative maximum length, also shown by the count.Unreleased
showCountbooleanfalseShows the length, and maxLength when set.Unreleased
rowsnumber3Rows of a textarea without autosize.Unreleased
autosizeboolean | { minRows?, maxRows? }falseGrows a textarea with its text, between the given rows.Unreleased
autoFocusbooleanfalseNative autofocus.Unreleased
inputPropsInputNativePropsundefinedMore attributes for the native element. Top-level props win; its type replaces a text field’s native type.Unreleased
refRef<HTMLInputElement | HTMLTextAreaElement>undefinedThe native input or textarea.Unreleased
wrapperRefRef<HTMLDivElement>undefinedThe bordered box, e.g. to anchor a popup to.Unreleased

className and style go to the bordered box. Every other native attribute and event, including onFocus, onBlur, onKeyDown, role and aria-*, goes to the native input or textarea. For a pair of values, use two Inputs.

InputGroup

InputGroup takes native div attributes and a ref. Give a group of related fields an aria-label or role="group" when it needs a name.

InputGroupLabel

NameTypeDefaultDescriptionVersion
sizetiny | small | medium | largemediumMatch it to the Inputs in the group.Unreleased

InputGroupLabel also takes native span attributes and a ref.