Playground

Login block

Email and password sign-in form with validation messages.

  • Built on native elements
  • A section named by its title; the form is named by the same heading.
  • Invalid submits show a role=alert summary whose links move focus to each field, and each field gets aria-invalid and an error message.
  • Email and password carry autocomplete hints for password managers.
  • Styles in one file: form.css

Import

import '@monoline/css';
import {BlockLogin} from '@monoline/react';

Not installed yet? Pick a route.

Copies the source and its styles into your project.

npx monoline add block-login

Usage

import {BlockLogin, Link} from '@monoline/react';

<BlockLogin
  description="Use the email you signed up with."
  footer={<><Link href="#">Forgot your password?</Link><Link href="#">Create an account</Link></>}
/>

Examples

Sign in

Submit empty to see the validation messages.

Props

BlockLoginProps

PropTypeDefaultDescription
titleReactNode'Sign in'Heading of the form. Default "Sign in".
descriptionReactNode–Optional muted line under the heading.
submitLabelReactNode'Sign in'Text of the submit button. Default "Sign in".
onSubmit((values: LoginValues) => void)–Called with the values once they pass validation.
loadingboolean–Shows a spinner on the submit button while you sign in.
footerReactNode–Links under the form: forgot password, create an account.
messagesPartial<{ email: string; emailInvalid: string; password: string; }>–Replace the validation messages (translate them, or change the tone).
headingLevel1 | 2 | 31Outline level of the title, 1 to 3. Default 1 because a login page is usually the page's h1.

Data Attributes

State is exposed through attributes. Style it with these selectors, not with class toggles.

AttributeStylesheet
[aria-checked="true"]03-form-fields.css
[aria-invalid="true"]03-form-fields.css
[aria-pressed="true"]03-form-fields.css
[data-valid="true"]11-field-states.css

CSS classes

ClassStylesheet
.formform.css
.form-actionsform.css
.form-errorsform.css
.form-errors-titleform.css
.field03-form-fields.css
.field-hint03-form-fields.css
.input03-form-fields.css
.input-bare03-form-fields.css
.input-end03-form-fields.css
.input-lg03-form-fields.css
.input-sm03-form-fields.css
.input-wrap03-form-fields.css
.muted03-form-fields.css
.seg03-form-fields.css
.seg-opt03-form-fields.css
.select03-form-fields.css
.setting03-form-fields.css
.switch03-form-fields.css
.textarea03-form-fields.css
.field-error11-field-states.css
.field-ok11-field-states.css
.field-required11-field-states.css
.form-row11-field-states.css
.input11-field-states.css
.input-affix11-field-states.css
.input-group11-field-states.css
.select11-field-states.css
.textarea11-field-states.css
.btn02-buttons.css
.btn-block02-buttons.css
.btn-danger02-buttons.css
.btn-ghost02-buttons.css
.btn-lg02-buttons.css
.btn-line02-buttons.css
.btn-sm02-buttons.css
.btn-solid02-buttons.css
.skeleton13-loading.css
.skeleton-block13-loading.css
.skeleton-hatch13-loading.css
.spinner13-loading.css
.headingheading.css
.heading-displayheading.css
.heading-lgheading.css
.heading-mdheading.css
.heading-smheading.css
.heading-xlheading.css
.texttext.css
.text-accenttext.css
.text-dangertext.css
.text-fulltext.css
.text-lgtext.css
.text-mdtext.css
.text-mutedtext.css
.text-oktext.css
.text-smtext.css
.text-successtext.css
.text-truncatetext.css
.text-warningtext.css
.text-xstext.css
.block-loginblock-login.css
.block-login-footerblock-login.css
.block-login-headblock-login.css

Customization

Style it with the kit's tokens in your own CSS, loaded after @monoline/css. Prefer the attributes above over extra classes. See Theming for every token.

app.css
.form {
  border-color: var(--accent);
}
.form[aria-checked="true"] {
  background: var(--wash);
}

Accessibility

  • A section named by its title; the form is named by the same heading.
  • Invalid submits show a role=alert summary whose links move focus to each field, and each field gets aria-invalid and an error message.
  • Email and password carry autocomplete hints for password managers.