Input
The catnip-input component provides a versatile, highly configurable form field for standard text entry, passwords, and multiline paragraphs. Shared label and supporting-text APIs are summarised on Inputs overview.
Overview
The catnip-input component renders robust native <input> or <textarea> elements with built-in accessibility handling. Key features include:
- Input modes: Use
text(oremail),password(native masking with a show/hide toggle), ortextarea(with configurable rows). - Semantic Intents: Apply
neutral,warning,danger, orsuccessstates to adjust borders and supporting text colors. Warning and success use the standard primary focus ring; danger uses the danger focus ring. - Supporting Text: Built-in integration with the internal
FieldSupportingTextprimitive to provide descriptions, helper text, or error messages directly linked viaaria-describedby. - Flexible Icons: Slot in leading or trailing icons, and optionally make the right icon an interactive, accessible button. For single-line
text/email,show-clear-buttonadds a trailing clear control while the value is non-empty (uses bundledinput.clearunlessclear-button-aria-labelis set); when a right icon is also configured, both controls remain visible.
Live example
Accessibility
- IDs & Labeling: Automatically generates fallback
idattributes if omitted, ensuring the native control is always addressable. Provides robustaria-describedbylinkage to supporting text. - Invalid State: When
intent="danger"is set,aria-invalid="true"is automatically applied to the underlying input for assistive technology. - Interactive Icons: If the generic right icon is clickable (
rightIconClickable), a validrightIconButtonAriaLabelis strictly required. Theshow-clear-buttontrailing control usesclear-button-aria-labelor the defaultinput.clearlabel. - Password masking: Renders a native
type="password"control, so browsers, password managers, screen readers, and mobile keyboards treat it as a secure field. The visibility toggle switches the control totype="text"and back; see Input — Guidelines — Password.