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

Input fields

Labels, hints, validation states, and prefix icons for text inputs.

Overview

Form text controls stack as .input (label + field + hint), .field (bordered control), and optional .field-group tabs for defined widths. Tokens --field-* set default sizing.

LayerSourceRole
Labelscss/components/_label.scss.label, required asterisk, tooltip
Fieldscss/components/_input.scss.field, states, icons, password
Input blockscss/components/_input.scss.input, .input__hint
Native selectscss/components/_input.scssselect.field__input inside .field
Textareascss/components/_textarea.scss.textarea-wrap, counter
Semanticstokens/semantic.cssBorders, surfaces, --text-error

Prerequisites

  • PimentCSS installed, Installation (input components ship in the default bundle).
  • Semantic colors, error and success hues from Colors.
  • Layout, optional width utilities; default max width is --field-width (17.5rem).

Anatomy

Prefer the .input wrapper so label, control, and hint share a 4px gap (--space-1). The native element sits in .field__input without its own border.

Labels

Required fields show an asterisk with aria-hidden="true" on the glyph (announce requirement in the label text or with aria-required on the input). Optional fields may use .label__optional. Tooltip buttons need an explicit aria-label.

Field states

States map to modifiers on .field. In production, rely on :hover, :focus-within, and validation attributes. Each variant has its own preview below (responsive grid, no nested scroll).

Empty

Placeholder only, no value.

Filled

A value is already entered.

With icon

Leading icon (search) with placeholder.

State previews use visible <label for> + matching id on each input.

ModifierWhen to use
.field--activeDoc / forced active border (--border-action-hover)
.field--focusDoc preview of focus ring (prefer :focus-within)
.field--errorValidation failed; pair with aria-invalid="true"
.field--successValid entry confirmed
.field--disabledDisabled input inside field

Input block (label + hint)

Stack label, field, and caption. Error hints use .input__hint--error and --text-error.

Help text below the field (caption).

This value is not valid.

Password

Add .password-toggle inside .field. Toggle updates type, button label, and aria-pressed (wired on this docs site).

Native select

Place a native <select> inside .field with class field__input. A chevron is drawn on the field (icon font). For rich listboxes, use Menu & dropdown.

Textarea

Long text uses .textarea-wrap with optional instructions and a live counter (aria-live="polite").

Instructions for the long field.

0 / 200

Defined field (prefix / suffix)

Wide controls (--field-width-defined, 26.875rem) use .input--defined and .field-group with pre/post tabs. Active tab uses --surface-action.

https://
.com
https://

Class reference

Optional namespace via Sass $prefix (empty by default).

ClassDescription
.labelCaption row; pair with for + input id
.label__requiredVisual asterisk (aria-hidden)
.label__optionalMuted “(optional)” suffix
.label__tooltipIcon button; requires aria-label
.fieldBordered control shell; :focus-within ring
.field__inputNative input (no border)
.field__iconLeading icon slot (aria-hidden)
.field--error / --successValidation borders
.inputVertical stack: label + field + hint
.input__hintCaption; --error / --success variants
.password-toggleShow/hide password control
.textarea-wrapTextarea stack with hint and counter
.textareaNative textarea inside .textarea-field
.field-groupPrefix/suffix tabs + field
.field-group__tab--activeHighlighted pre/post segment

Customize (Sass)

  1. Field sizing tokens

    Override widths and padding when importing PimentCSS. Values feed --field-* CSS variables.
    @use "pimentcss-design-system" with (
      $field-width: 20rem,
      $field-width-defined: 28rem,
      $field-min-height: 2.75rem,
    );
  2. Rebuild CSS

    Regenerate dist/pimentcss.min.css after Sass changes.
    npm run build:css

See Customization for partial imports.

Accessibility (RGAA / WCAG)

Forms without barriers

  • Labels, every input has a visible label and matching id. Do not use placeholder as the only label.
  • Errors, set aria-invalid="true" and link the message with aria-describedby (hint paragraph id).
  • Required, use required or aria-required="true" plus text or asterisk explained in copy.
  • Focus, keyboard users get :focus-within ring on .field / .textarea-field (--border-focus, 3px).
  • Password toggle, update aria-pressed when visibility changes; keep button text meaningful (Show / Hide).
  • Contrast, body and hint text on --surface-primary ≥ 4.5:1; verify in light and dark (Colors).

Next steps