Skip to main content

Reset Password Block

The ResetPassword Component is a fully customizable and accessible reset password form built with React and TypeScript. It provides a complete password reset interface with modern design patterns, dual-view support for both request and confirmation flows, and flexible customization options.


🚀 Installation

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

📖 Usage

import {ResetPassword} from '@nodeblocks/frontend-reset-password-block';
Live Editor
function BasicResetPassword() {

  const [view, setView] = useState<'request' | 'confirm_password'>('request');

  return (
    <ResetPassword
      view={view}
      onSendRequest={formData => {
        console.log('Reset request sent:', formData);
        setView('confirm_password');
      }}
      onResetPassword={formData => {
        console.log('Password reset:', formData);
        setView('request');
      }}>
      <ResetPassword.Title>
        {view === 'request' ? 'Reset Your Password' : 'Confirm Password'}
      </ResetPassword.Title>
      <ResetPassword.Description>
        {view === 'request' ? 'Enter your email to receive reset instructions' : 'Enter your new password'}
      </ResetPassword.Description>
      <ResetPassword.Form>
        <ResetPassword.Form.EmailField label="Email Address" placeholder="Enter your email" />
        <ResetPassword.Form.PasswordField label="New Password" placeholder="Enter new password" />
        <ResetPassword.Form.ConfirmPasswordField label="Confirm Password" placeholder="Confirm new password" />
        <ResetPassword.Form.ResetPasswordButton>Reset Password</ResetPassword.Form.ResetPasswordButton>
      </ResetPassword.Form>
      <ResetPassword.Goto>
        <a href="#signin">Back to Sign In</a>
      </ResetPassword.Goto>
    </ResetPassword>
  );
}
Result
Loading...

🔧 Props Reference

Main Component Props

The main ResetPassword component inherits all props from the HTML div element (except children and onSubmit which are overridden) and adds:

PropTypeDefaultDescription
view'request' | 'confirm_password'RequiredDetermines which view to display - either email request form or password confirmation form
onSendRequest(data: T) => voidRequiredCallback function triggered when reset request is submitted
onResetPassword(data: T) => voidRequiredCallback function triggered when new password is submitted
resetPasswordTitleReactNode"Reset Password"Title content for the reset password form
descriptionReactNode"Please enter your email address you registered"Description text displayed below the title
gotoSigninMessageReactNodeDefault signin linkContent for the navigation link section
classNamestringundefinedAdditional CSS class name for styling the form container
directionenum"column"Flex direction for action buttons
alignItemsenum"stretch"Alignment of items in the container
gapSizeenum"S"Gap between items in the container
childrenBlocksOverrideundefinedCustom block components to override default rendering

Sub-Components

The ResetPassword component provides several sub-components. All sub-components receive their default values from the main component's context and can override these values through props.

ResetPassword.Title

PropTypeDefaultDescription
childrenReactNodeFrom contextTitle content - overrides errorTitle from context
sizeenum"2XL"Typography size for the title
typeenum"heading"Typography type
colorenum"low-emphasis"Color theme for the title
weightenum"bold"Weight of the title
classNamestringundefinedAdditional CSS class name for styling

ResetPassword.Description

PropTypeDefaultDescription
childrenReactNodeFrom contextTitle content - overrides errorTitle from context
sizeenum"M"Typography size for the title
typeenum"paragraph"Typography type
colorenum"low-emphasis"Color theme for the title
weightenum"regular"Weight of the title
classNamestringundefinedAdditional CSS class name for styling

ResetPassword.Form

PropTypeDefaultDescription
view'request' | 'confirm_password'Inherited from parentDetermines which fields to display
onSendRequest(data: T) => voidInherited from parentCallback for email submission
onResetPassword(data: T) => voidInherited from parentCallback for password confirmation
classNamestringundefinedAdditional CSS class name for styling
childrenReactNodeFrom contextCustom form content

ResetPassword.Form.EmailField

PropTypeDefaultDescription
namestring"email"Field name used for form data
errorTextstringundefinedError text for the input
isDisabledbooleanundefinedWhether the input is disabled
isRequiredbooleanundefinedWhether the input is required
labelstring"Email"Label of the input field
labelWeightenum"bold"Label weight
classNamestringundefinedAdditional CSS class name for styling

Note: This component additional inherits some common HTML input element props.

ResetPassword.Form.PasswordField

PropTypeDefaultDescription
namestring"password"Field name used for form data
errorTextstringundefinedError text for the input
isDisabledbooleanundefinedWhether the input is disabled
isRequiredbooleanundefinedWhether the input is required
labelstring"Password"Label of the input field
labelWeightenum"bold"Label weight
classNamestringundefinedAdditional CSS class name for styling
showPasswordbooleanundefinedWhether to show password
onShowPasswordClickfunctionundefinedFunction to handle password visibility toggle

Note: This component additional inherits some common HTML input element props.

ResetPassword.Form.ConfirmPasswordField

PropTypeDefaultDescription
namestring"confirmPassword"Field name used for form data
errorTextstringundefinedError text for the input
isDisabledbooleanundefinedWhether the input is disabled
isRequiredbooleanundefinedWhether the input is required
labelstring"Confirm Password"Label of the input field
labelWeightenum"bold"Label weight
classNamestringundefinedAdditional CSS class name for styling
showPasswordbooleanundefinedWhether to show password
onShowPasswordClickfunctionundefinedFunction to handle password visibility toggle

Note: This component additional inherits some common HTML input element props.

ResetPassword.Form.ResetPasswordButton

PropTypeDefaultDescription
childrenReactNodeFrom contextText to place inside the button
classNamestringundefinedAdditional CSS class name for styling
fillenum"fill"Button fill style
iconenumundefinedOptional icon for the left-hand side of the button
iconColorenumundefinedColor for the left-hand side icon. When not provided, a default color for the fill type will be used.
isDisabledbooleanfalseWhether the button is disabled and cannot be used
onClickfunctionundefinedFunction to handle button click
sizeenum"M"Button vertical size
textAlignenum"center"Button icon and text positioning within the button
textColorenum"default"Button text color
textEmphasisbooleanfalseButton text weight
textSizeenum"M"Button text size
typeenum"submit"Button purpose (affects html type)

Note: This component additional inherits some common HTML button element props.

ResetPassword.Goto

PropTypeDefaultDescription
childrenReactNodeDefault signin linkContent for the navigation link section - typically contains an anchor tag
classNamestringundefinedAdditional CSS class name for styling

🔧 TypeScript Support

Full TypeScript support with comprehensive type definitions:

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

// Default form data structure for email request
interface ResetPasswordEmailData {
email?: string;
}

// Default form data structure for password confirmation
interface ResetPasswordConfirmData {
password?: string;
confirmPassword?: string;
}

// Combined form data type
type ResetPasswordFormData = ResetPasswordEmailData | ResetPasswordConfirmData;

// Extend with custom fields
interface CustomResetPasswordFormData extends ResetPasswordFormData {
customField?: string;
}

const MyResetPasswordForm = () => {
const handleSendRequest = (formData: ResetPasswordFormData) => {
console.log('Reset request sent:', formData);
// Handle email submission
};

const handleResetPassword = (formData: ResetPasswordFormData) => {
console.log('Password reset:', formData);
// Handle password reset
};

return (
<ResetPassword<CustomResetPasswordFormData>
view="request"
onSendRequest={handleSendRequest}
onResetPassword={handleResetPassword}
resetPasswordTitle="Forgot Your Password?"
description="Enter your email address and we'll send you reset instructions">
<ResetPassword.Title>Reset Your Password</ResetPassword.Title>
<ResetPassword.Description>
Don't worry, it happens to everyone. Enter your email below.
</ResetPassword.Description>
<ResetPassword.Form>
<ResetPassword.Form.EmailField />
<ResetPassword.Form.PasswordField />
<ResetPassword.Form.ConfirmPasswordField />
<ResetPassword.Form.ResetPasswordButton>Send Reset Link</ResetPassword.Form.ResetPasswordButton>
</ResetPassword.Form>
<ResetPassword.Goto>
<span>
Remember your password? <a href="/signin">Sign In</a>
</span>
</ResetPassword.Goto>
</ResetPassword>
);
};

Built with ❤️ using React, TypeScript, and modern web standards.