Skip to main content
PimentCSS v1.0.1, what's new
Home

Form

Vertical form layout with fields, actions, and validation messaging.

Overview

.form is a centered panel (max 328px) that stacks a heading, field rows, an optional checkbox row, and a full-width primary action. Default spacing: 24px padding, 48px between title and body, 16px between fields.

PartClassRole
Panel.formSurface, padding, vertical rhythm
Title.form__titleHeading styled as h4 token
Fields stack.form__bodyInputs + optional checkbox
Row.form__fieldLabel + one .field or .textarea
Actions.form__actionsFull-width .btn

Prerequisites

Structure

Wrap fields in .form__field so label-to-control gap (4px) and field width (280px) stay consistent. Checkbox uses .form__checkbox on the label for full-width alignment inside the body.

Contact form example

Interactive demo combining text inputs, native select, radio group, textarea, validation error, checkbox, and submit. All controls use PimentCSS form patterns.

Contact us

Enter a valid email address.

Preferred contact

Optional, 500 characters max in production.

Field row

Each .form__field is a column: .label then .field (or .textarea). Icons and validation states come from the field component; the form only sets width and vertical gap.

Checkbox in the form

Add .form__checkbox on the checkbox label so it spans the body width and aligns with touch targets. Keep the native input first, then .checkbox__control, then text.

Actions

.form__actions stretches child buttons to 100% width. Pair with .btn--primary for the main submit.

Class reference

ClassDescription
.formRoot panel; flex column, centered, surface background
.form__titleTitle using heading h4 tokens
.form__bodyStack of fields and optional checkbox
.form__fieldSingle label + control row (280px max)
.form__checkboxFull-width checkbox label variant
.form__fieldsetRadio group with legend inside the body
.form__radioFull-width radio label variant
.form__actionsFooter actions; buttons fill width

Customize (Sass)

  1. Form spacing

    Override panel width and gaps before importing components.
    @use "pimentcss-design-system" with (
      $form-max-width: 22rem,
      $form-gap: 2.5rem,
      $form-body-gap: 1rem
    );
  2. Rebuild CSS

    Run after editing _form.scss or tokens.
    npm run build:css

Accessibility (RGAA / WCAG)

Forms

  • Labels, every input has a visible <label for="…"> matching id.
  • Required fields, use required and aria-required="true" when applicable; show errors with aria-invalid on the control.
  • Submit, use type="submit" on the primary button; do not rely on Enter in a single-field page without a form element.
  • Autocomplete, set meaningful autocomplete values (e.g. name, email, tel).
  • Checkbox copy, label text describes the consent; checked state must be perceivable (not color alone).
  • Focus, focus-visible on inputs, checkbox, and submit for keyboard users.

Next steps