Skip to the content

Input

Input is the single-line text field. It takes every native <input> prop except size, which is the size token. InputMask, InputCurrency and InputDate render it, so they share its sizes, states and icon slot.
Forms

When to use

Use when
  • Collecting free text: names, e-mails, passwords, search terms.
  • A field needs validation feedback (variant="error" or "success").
Avoid when
  • The text spans several lines — use TextArea.
  • The value comes from a list — use Select or InputSelect.
  • The value has a fixed format (phone, money, date) — use InputMask or its siblings.

Usage

const [name, setName] = useState('');

<Input aria-label="Name" placeholder="Type your name" value={name} onChange={(e) => setName(e.target.value)} />;

Leave value undefined to use the input uncontrolled with defaultValue.

Sizes

<Input size="compact" placeholder="compact" />

Each size reads theme.component.input.size.<size> (py, fontSize, borderRadius, height); override one field with createTheme({ component: { input: { size: { medium: { py: 'small' } } } } }).

Icons and states

<Input iconPosition="left" icon={<Icon icon={search} />} />
<Input variant="error" />
<Input variant="success" />

error and success show a status icon when no icon is set. Without any variant, a native constraint (required, pattern, …) paints the error border once the user has interacted (:user-invalid); an explicit variant, including 'default', turns that off. Field always passes one.

Clearing

clearable shows a clear button while there is a value and the input is not readOnly. Standalone, pass reset to clear your state; inside a Form, Field injects it.

<Input clearable value={value} onChange={(e) => setValue(e.target.value)} reset={() => setValue('')} />

Accessibility

  • Input renders no label: wrap it in Field or pass aria-label.
  • The clear button is a native <button> reachable with Tab, named by clearLabel (default Limpar).

Properties

Placement props (area, alignSelf, justifySelf) apply to the wrapper.

See also