Authentication forms
Sign-in, registration, password-recovery and server-validation examples composed from forms, inputs, checkboxes, buttons, alerts and utility classes.
These examples cover signing in, recovering access and creating an account. Each form pairs visible labels with native inputs and shows where guidance or validation feedback belongs. Submitting a demo displays a local notification; connect the form to your application’s account service for real authentication.
The HTML tabs show essential markup; layout wrappers, repeated content, secondary details and demo behavior are omitted.
Sign in
Use a form-level alert for a credential error when no single field caused the failure. A generic message avoids revealing whether an account exists.
Essential markup
<form class="card" action="/sessions" method="post" aria-labelledby="authentication-sign-in-title">
<h3 id="authentication-sign-in-title">Sign in</h3>
<div class="alert bg-error" role="alert">
<div class="alert-content">
<p class="alert-title">We could not sign you in</p>
<p class="alert-message">Check your email and password, then try again.</p>
</div>
</div>
<label class="form-label is-required" for="signInEmail">Email address</label>
<input class="form-control" id="signInEmail" name="email" type="email" autocomplete="username" required />
<label class="form-label is-required" for="signInPassword">Password</label>
<input class="form-control" id="signInPassword" name="password" type="password" autocomplete="current-password" required />
<a href="#authentication-password-recovery-title">Forgot your password?</a>
<div class="form-check">
<input class="form-check-input" id="rememberSignIn" name="remember" type="checkbox" value="yes" />
<label class="form-label" for="rememberSignIn">Keep me signed in</label>
</div>
<button class="btn btn-solid btn-primary" type="submit">Sign in</button>
</form>Password recovery
Ask only for the account identifier needed to start recovery. Return the same generic response whether the account exists so the form does not expose registered email addresses.
Essential markup
<form class="card" action="/password-recovery" method="post" aria-labelledby="authentication-password-recovery-title">
<h3 id="authentication-password-recovery-title">Reset your password</h3>
<p>If an account matches the address, we will send password-reset instructions.</p>
<label class="form-label is-required" for="recoveryEmail">Email address</label>
<input class="form-control" id="recoveryEmail" name="email" type="email" autocomplete="username" required />
<a class="btn btn-text btn-secondary" href="#authentication-sign-in-title">Back to sign in</a>
<button class="btn btn-solid btn-primary" type="submit">Send reset link</button>
</form>Registration with server validation
On an unsuccessful server response, move focus to the error summary and link each message to its field. Preserve safe text and choice values so users only correct the errors; clear password fields instead of returning secrets in HTML.
Essential markup
<form class="card" action="/accounts" method="post" aria-labelledby="authentication-server-validation-title">
<h3 id="authentication-server-validation-title">Create an account</h3>
<div class="alert bg-error" role="alert" aria-labelledby="registrationErrorSummaryTitle" autofocus tabindex="-1">
<div class="alert-content">
<h4 class="alert-title" id="registrationErrorSummaryTitle">There are two errors to correct</h4>
<ul>
<li><a href="#serverRegistrationEmail">Use a different email address</a></li>
<li><a href="#serverRegistrationPassword">Choose a password that has not appeared in a known data breach</a></li>
</ul>
</div>
</div>
<!-- Preserve safe values; never return passwords in the HTML response. -->
<label class="form-label is-required" for="serverRegistrationEmail">Email address</label>
<input class="form-control is-invalid" id="serverRegistrationEmail" name="email" type="email"
value="john.doe@example.com" autocomplete="email" required
aria-invalid="true" aria-describedby="serverRegistrationEmailFeedback" />
<div class="invalid-feedback" id="serverRegistrationEmailFeedback">An account already uses this email address.</div>
<label class="form-label is-required" for="serverRegistrationPassword">Password</label>
<input class="form-control is-invalid" id="serverRegistrationPassword" name="password" type="password"
autocomplete="new-password" minlength="12" required aria-invalid="true"
aria-describedby="serverRegistrationPasswordHint serverRegistrationPasswordFeedback" />
<small id="serverRegistrationPasswordHint">Use at least 12 characters.</small>
<div class="invalid-feedback" id="serverRegistrationPasswordFeedback">Choose a password that has not appeared in a known data breach.</div>
<!-- Name, password confirmation and accepted terms omitted. -->
<button class="btn btn-solid btn-primary" type="submit">Create account</button>
</form>Registration
Pair every required field with its visible label, and expose password guidance through aria-describedby. Give required checkboxes an explicit submission value.
Essential markup
<form class="card" action="/accounts" method="post" aria-labelledby="authentication-registration-title">
<h3 id="authentication-registration-title">Create an account</h3>
<label class="form-label is-required" for="registrationName">Full name</label>
<input class="form-control" id="registrationName" name="name" type="text" autocomplete="name" required />
<label class="form-label is-required" for="registrationEmail">Email address</label>
<input class="form-control" id="registrationEmail" name="email" type="email" autocomplete="email" required />
<label class="form-label is-required" for="registrationPassword">Password</label>
<input class="form-control" id="registrationPassword" name="password" type="password"
autocomplete="new-password" minlength="12" aria-describedby="registrationPasswordHint" required />
<small class="text-muted" id="registrationPasswordHint">Use at least 12 characters.</small>
<label class="form-label is-required" for="registrationPasswordConfirmation">Confirm password</label>
<input class="form-control" id="registrationPasswordConfirmation" name="passwordConfirmation"
type="password" autocomplete="new-password" required />
<div class="form-check">
<input class="form-check-input" id="acceptTerms" name="terms" type="checkbox" value="accepted" required />
<label class="form-label is-required" for="acceptTerms">I accept the terms and data policy</label>
</div>
<button class="btn btn-solid btn-primary" type="submit">Create account</button>
</form>Built with
- Form and Input for labels, required fields, guidance and validation feedback.
- Checkbox for remembered sessions and required consent.
- Button for submission and secondary navigation actions.
- Alert for form-level errors and a linked error summary.
- Card and Icon for form structure and decorative status icons.
- Flex, Sizing and Spacings for responsive form layouts.