Skip to main content

Change Password Block

ChangePassword is a controlled change-password form block built on MUI.

Installationโ€‹

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

What You Needโ€‹

ItemWhy it matters
dataSingle source of truth for form state (currentPassword, newPassword, confirmPassword)
onDataChangeReceives updated state + metadata on field changes; meta includes name, value, cause (input, change, blur, clear, reset, programmatic), optional event
errors (optional)Displays field-level error feedback
resetPasswordUrl (optional)Target URL for the forgot-password link
Controlled component

ChangePassword does not own form state. Keep state in your app and pass it through data.

Code Examplesโ€‹

Live Editor
function Example() {
  const defaultData = {
    currentPassword: '',
    newPassword: '',
    confirmPassword: '',
  };

  const [data, setData] = React.useState(defaultData);

  return (
    <ChangePassword
      data={data}
      onDataChange={setData}
      onSubmit={e => {
        e.preventDefault();
        alert(`Submit:\n${JSON.stringify(data, null, 2)}`);
      }}
    />
  );
}
Result
Loading...

Important Propsโ€‹

Core Propsโ€‹

PropTypeRequiredDefaultDescription
dataChangePasswordFormData ({ currentPassword?, newPassword?, confirmPassword? } or extended Record<string, unknown>)Yes-Current form data object
onDataChange(data, meta) => voidYes-Called on updates; meta includes name, value, cause (input, change, blur, clear, reset, programmatic), optional event
errors{ [fieldName: string]: string | string[] }NoundefinedField errors keyed by data field name (currentPassword, newPassword, confirmPassword)

Content Propsโ€‹

PropTypeRequiredDefaultDescription
resetPasswordUrlstringNo/auth/resetpasswordURL for Form.ResetPasswordLink (link text default: ใƒ‘ใ‚นใƒฏใƒผใƒ‰ใ‚’ๅฟ˜ใ‚ŒใŸๆ–น)

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

ChangePassword also inherits StackProps<'form'> (except children), so standard form props like onSubmit, id, and noValidate are supported. Default block order without overrides: title, form (defaultBlockOrder).

Default UI Blocksโ€‹

BlockBuilt onNotes
ChangePassword (root)Stack (component="form")Controlled form container; inner content max width 684px
ChangePassword.TitleTypographyTitle (variant="h6"); default ใƒ‘ใ‚นใƒฏใƒผใƒ‰ใ‚’ๅค‰ๆ›ด
ChangePassword.FormStackForm fields container (submit handled by root form)
ChangePassword.Form.CurrentPasswordFieldTextField + IconButtonDefault label/placeholder ็พๅœจใฎใƒ‘ใ‚นใƒฏใƒผใƒ‰ / ็พๅœจใฎใƒ‘ใ‚นใƒฏใƒผใƒ‰ใ‚’ๅ…ฅๅŠ›
ChangePassword.Form.ResetPasswordLinkBox + LinkDefault link text ใƒ‘ใ‚นใƒฏใƒผใƒ‰ใ‚’ๅฟ˜ใ‚ŒใŸๆ–น; href falls back to resetPasswordUrl or /auth/resetpassword
ChangePassword.Form.NewPasswordFieldTextField + IconButtonDefault ๆ–ฐใ—ใ„ใƒ‘ใ‚นใƒฏใƒผใƒ‰ / ๆ–ฐใ—ใ„ใƒ‘ใ‚นใƒฏใƒผใƒ‰ใ‚’ๅ…ฅๅŠ›
ChangePassword.Form.ConfirmPasswordFieldTextField + IconButtonDefault ๆ–ฐใ—ใ„ใƒ‘ใ‚นใƒฏใƒผใƒ‰ใ‚’ๅ†ๅ…ฅๅŠ› (label and placeholder)
ChangePassword.Form.ChangePasswordButtonButtonSubmit (variant="contained", type="submit"); default ใƒ‘ใ‚นใƒฏใƒผใƒ‰ใ‚’ๅค‰ๆ›ด

TypeScriptโ€‹

import {ChangePassword, ChangePasswordFormData} from '@nodeblocks/frontend-change-password-block';

type MyChangePasswordData = ChangePasswordFormData & {
userId?: string;
};