Skip to content
+

Input

The Input component provides users with a field to enter and edit text.

useInput API

Import

import { useInput } from '@mui/base/useInput';
// or
import { useInput } from '@mui/base';
Learn about the difference by reading this guide on minimizing bundle size.

Parameters

NameTypeDefaultDescription
defaultValueunknown

The default value. Use when the component is not controlled.

disabledboolean

If true, the component is disabled. The prop defaults to the value (false) inherited from the parent FormControl component.

errorboolean

If true, the input will indicate an error by setting the aria-invalid attribute. The prop defaults to the value (false) inherited from the parent FormControl component.

inputRefReact.Ref<HTMLInputElement | HTMLTextAreaElement>
onBlurReact.FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>
onChangeReact.ChangeEventHandler<HTMLInputElement | HTMLTextAreaElement>
onClickReact.MouseEventHandler
onFocusReact.FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>
requiredboolean

If true, the input element is required. The prop defaults to the value (false) inherited from the parent FormControl component.

valueunknown

Return value

NameTypeDefaultDescription
disabledboolean

If true, the component will be disabled.

errorboolean

If true, the input will indicate an error by setting the aria-invalid attribute.

focusedboolean

If true, the input will be focused.

formControlContextFormControlState | undefined

Return value from the useFormControlContext hook.

getInputProps<ExternalProps extends Record<string, any> = {}>(externalProps?: ExternalProps) => UseInputInputSlotProps<ExternalProps>

Resolver for the input slot's props.

getRootProps<ExternalProps extends Record<string, any> = {}>(externalProps?: ExternalProps) => UseInputRootSlotProps<ExternalProps>

Resolver for the root slot's props.

inputRefReact.RefCallback<HTMLInputElement | HTMLTextAreaElement> | null
requiredboolean

If true, the input will indicate that it's required.

valueunknown

The value of the input element.