Skip to main content

Reset Password Block

ResetPassword is a controlled two-step reset flow (request and confirm_password) built on MUI.

Installation

npm install @nodeblocks/frontend-reset-password-block

What You Need

ItemWhy it matters
dataSingle source of truth for form state
onDataChangeReceives updated state + metadata on field changes
viewSwitches between email request and password confirmation UI
onSendRequestCalled when the request form is submitted (view="request")
onResetPasswordCalled when the confirm form is submitted (view="confirm_password")
errors (optional)Displays field-level error feedback
Controlled component and view

ResetPassword does not own form state. Keep state in your app and pass it through data. Use view="request" with { email } data, or view="confirm_password" with { password, confirmPassword } data.

Code Examples

Live Editor
function Example() {
  const [view] = React.useState('request');
  const [data, setData] = React.useState({email: ''});

  return (
    <ResetPassword
      view={view}
      data={data}
      onDataChange={setData}
      onSendRequest={formData => {
        alert(`Send request:\n${JSON.stringify(formData, null, 2)}`);
      }}
      onResetPassword={formData => {
        alert(`Reset password:\n${JSON.stringify(formData, null, 2)}`);
      }}
    />
  );
}
Result
Loading...

Important Props

Core Props

PropTypeRequiredDefaultDescription
dataResetPasswordFormData ({ email? } or { password?, confirmPassword? }, or extended Record<string, unknown>)Yes-Current form data; shape should match view
onDataChange(data, meta) => voidYes-Called on updates; meta includes name, value, cause (input, change, blur, clear, reset, programmatic), optional event
view'request' | 'confirm_password'Yes'request'Active step of the reset flow
onSendRequest(data) => voidYes-Submit handler for view="request"
onResetPassword(data) => voidYes-Submit handler for view="confirm_password"
errors{ [fieldName: string]: string | string[] }NoundefinedField errors keyed by data field name (e.g. email, password, confirmPassword)

Content Props

PropTypeRequiredDefaultDescription
resetPasswordTitleReactNodeNo'Reset Password'Title content
descriptionReactNodeNo'Please enter your email address you registered'Description below the title; pass null to hide
labels{ emailField?, passwordField?, confirmPasswordField?, resetPasswordButton? }NoemailField: 'Email', passwordField: 'Password', confirmPasswordField: 'Confirm Password', resetPasswordButton: 'Reset Password'Override field and button labels
placeholders{ emailField?, passwordField?, confirmPasswordField? }NoemailField: 'Please enter your email', passwordField: 'Please enter your new password', confirmPasswordField: 'Please confirm your password'Override field placeholders
showPasswordbooleanNointernal falsePassword visibility for Form.PasswordField (confirm_password view)
onShowPasswordClick(show: boolean) => voidNointernal togglePassword visibility handler
showConfirmPasswordbooleanNointernal falseConfirm-password visibility for Form.ConfirmPasswordField
onShowConfirmPasswordClick(show: boolean) => voidNointernal toggleConfirm-password visibility handler

Layout and Composition Props

PropTypeRequiredDefaultDescription
childrenBlocksOverride | ReactNodeNoundefinedOverride default blocks or provide custom JSX children
componentReact.ElementTypeNo'form'Root element type
classNamestringNoundefinedClass name for the root container
sxSxPropsNoundefinedMUI system styles for the root container

ResetPassword also inherits StackProps (except children and onSubmit), so standard stack props like id, spacing, and component are supported. Form submit is handled inside ResetPassword.Form. Default block order without overrides: title, description, form (defaultBlockOrder).

Default UI Blocks

BlockBuilt onNotes
ResetPassword (root)StackControlled container; default component="form"; submit handlers live on Form
ResetPassword.TitleTypographyTitle text block (variant="h4"); default Reset Password
ResetPassword.DescriptionTypographyDescription text (variant="body2"); default Please enter your email address you registered; hidden when description is null
ResetPassword.FormStack (component="form")Form container; calls onSendRequest or onResetPassword by view
ResetPassword.Form.EmailFieldTextFieldShown only when view="request"; name="email"; default Email / Please enter your email
ResetPassword.Form.PasswordFieldTextField + IconButtonShown only when view="confirm_password"; name="password"; default Password / Please enter your new password; visibility toggle
ResetPassword.Form.ConfirmPasswordFieldTextField + IconButtonShown only when view="confirm_password"; name="confirmPassword"; default Confirm Password / Please confirm your password; separate visibility toggle
ResetPassword.Form.ResetPasswordButtonButtonSubmit button (variant="contained", type="submit"); default Reset Password

TypeScript

import {ResetPassword, ResetPasswordFormData} from '@nodeblocks/frontend-reset-password-block';

type MyResetPasswordData = ResetPasswordFormData & {
token?: string;
};