Playground

Sign-up block

Name, email and password account 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.
  • The password hint states the minimum length; autocomplete hints are set.
  • Styles in one file: form.css

Import

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

Not installed yet? Pick a route.

Copies the source and its styles into your project.

npx monoline add block-signup

Usage

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

<BlockSignup
  description="It takes a minute."
  footer={<span>Already have an account? <Link href="#">Sign in</Link></span>}
/>

Examples

Create an account

Submit empty to see the validation messages.

Props

BlockSignupProps

PropTypeDefaultDescription
titleReactNode'Create your account'Heading of the form. Default "Create your account".
descriptionReactNode–Optional muted line under the heading.
submitLabelReactNode'Create account'Text of the submit button. Default "Create account".
onSubmit((values: SignupValues) => 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<{ name: string; email: string; emailInvalid: string; password: string; passwordShort: string; }>–Replace the validation messages (translate them, or change the tone).
passwordMinnumber8Shortest password accepted. Default 8.
headingLevel1 | 2 | 31Outline level of the title, 1 to 3. Default 1 because a signup 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-signupblock-signup.css
.block-signup-footerblock-signup.css
.block-signup-headblock-signup.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.
  • The password hint states the minimum length; autocomplete hints are set.