Forgot password

Resetting a password in the sign-in card: the e-mail field, then a confirmation that the link is on its way.

Open full screen

Inset · No navigation. <AppShell direction="inset">, the default: the navigation on the grey app frame, the page a raised white card inside it, scrolling within.

npx wideset add block-forgot-password

Import the default export from @/blocks/wideset/forgot-password. The files below are relative to your project's source directory.

Installed with this block
  • block-styles
  • button
  • form-field
  • text-input
  • toast
  • utils
blocks/wideset/forgot-password/index.tsx
'use client';

import '@/styles/wideset-blocks.css';

import { ToastProvider } from '@/components/ui/wideset/toast/Toast.context';
import { useState } from 'react';

import { AuthCard } from './auth-card';
import { ROUTES } from './data';
import { LinkSent } from './link-sent';
import { ResetForm } from './reset-form';

/**
 * Forgot password, Inset direction with no navigation: the sign-in card asking for an e-mail, then
 * saying the reset link is on its way.
 */
export default function ForgotPassword() {
  const [email, setEmail] = useState('');
  const [sent, setSent] = useState(false);

  return (
    <ToastProvider position="bottom-center">
      <main className="ws-block-utility bg-ws-static-background p-ws-12 flex min-h-dvh items-center justify-center">
        <AuthCard
          other={{ href: ROUTES.signUp, label: 'Create account' }}
          className="w-full max-w-[38.75rem]"
        >
          {sent ? (
            <LinkSent email={email.trim()} onChangeEmail={() => setSent(false)} />
          ) : (
            <ResetForm email={email} onEmailChange={setEmail} onSent={() => setSent(true)} />
          )}
        </AuthCard>
      </main>
    </ToastProvider>
  );
}