Login Form

Email and password, with somewhere for SSO buttons and an error. The error is announced, not just coloured — a failed sign-in that only turns red is invisible to a screen reader.

src/components/ui/login-form.tsx

About

From the component's own source, where it was written.

Email and password sign-in, with providers.

The error is deliberately generic and lives above the form, not on a field. "No account with that email" tells an attacker which addresses are registered; a single "those details do not match" on the form as a whole leaks nothing and is what every audited implementation does.

Field names and autocomplete tokens are the real ones — username and current-password — because password managers key off them, and a login form they cannot fill is one people work around by choosing weaker passwords.

Install

npx astralyx-ui add login-form

Usage

import { LoginForm } from '@/components/ui/login-form'

<LoginForm onSubmit={signIn} onForgot={reset} error={error} />

Composer

Change the props and the source below follows.

Sign in

or
Props
tsx
<LoginForm onSubmit={signIn} onForgot={reset} error={error} />

Examples

With SSO providers and a failure

Submitting

API

Generated from the source, so it cannot fall behind the code. One table per exported component, then hooks, functions and types.

LoginForm

Email and password sign-in, with providers.

Extends Omit<ComponentProps<'form'>, 'onSubmit' | 'title'>.

PropTypeDefaultDescription
onSubmit(credentials: { email: string; password: string }) => void—Called on submit with the two values. The form never navigates on its own.
onForgot() => void——
providersReactNode—Slot for SSO or OAuth buttons, placed above the fields — where people who use them actually look.
errorReactNode—Rendered in a live region above the fields and referenced by aria-describedby, so it is read on failure rather than merely seen.
loadingbooleanfalseDisables the submit button and shows a spinner. The fields stay enabled, so a slow request does not eat a correction.
titleReactNode'Sign in'—
descriptionReactNode——
footerReactNode——
emailLabelReactNode'Email'—
passwordLabelReactNode'Password'—
forgotLabelReactNode'Forgot password?'—
submitLabelReactNode'Sign in'—
dividerLabelReactNode'or'Separates the provider buttons from the fields.
titleAs'h1' | 'h2' | 'h3' | 'p''h2'Element for the title.

Behaviour

TopicDetailDescription
autocompletesetusername and current-password, which is what lets a password manager fill both in one gesture.