Skip to main content
Version: v3

RHFPasswordInput

RHFPasswordInput extends the TextField component, designed specifically for password input on signup and login pages. This component allows users to toggle password visibility, offering a more user-friendly experience when entering credentials.

Usage

import RHFPasswordInput, { RHFPasswordInputProps } from '@nish1896/rhf-mui-components/mui/password-input';

RHFPasswordInput also requires just 3-4 essential props to render a fully functional field.

<RHFPasswordInput
fieldName="password"
control={control}
errorMessage={errors?.password?.message}
/>

Examples

API

The RHFPasswordInputProps interface extends TextFieldProps and includes additional options for password handling and input customization.

NameTypeRequiredDescription
fieldNamestringReact Hook Form requires name as a key for the registration process. This is a required prop for all components.
controlUseFormControlThe control option yielded on calling the useForm hook.
registerOptionsRegisterOptionsRegister options for validation if using react-hook-form without any validation libraries like yup or Joi.
onValueChange(value: string, event: ChangeEvent) => voidAn optional callback function when the value of a field changes.
showLabelAboveFormFieldbooleanRender form label above the form field in FormLabel component.
formLabelPropsFormLabelPropsFormLabelProps to customise FormLabel component for a field. Multiple fields can be configured using the ConfigProvider component.
showPasswordIconReactNodeIcon component to show password, such as VisibilityIcon from @mui/icons-material/Visibility.
hidePasswordIconReactNodeIcon component to hide password text, such as VisibilityOffIcon from @mui/icons-material/VisibilityOff.
errorMessageReactNodeError message to be shown for a field in FormHelperText component.
hideErrorMessagebooleanA flag to prevent replacement of helper text of a field by the error message when the validation is triggered.
formHelperTextPropsFormHelperTextPropsFormHelperTextProps to customise FormHelperText component for a field. Multiple fields can be configured using the ConfigProvider component.