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
Guidelines
The catnip-input component is a flexible form field designed for text entry, passwords, and multiline paragraphs. For dates, use Date Input. For phone numbers with a country-code picker, use Phone Input. For multi-value tag entry, use Chip Input.
Types (catnip-input)
Text & Email (type="text" | "email")
Use the default text type for standard single-line data entry. Use email when you need mobile browsers to show an email-optimized keyboard.
Password (type="password")
Use for sensitive text entry. The control is a native type="password" input, so the browser masks the value with its own characters and password managers, autofill, screen readers, and mobile keyboards treat it as a secure field.
- The trailing eye button toggles visibility by switching the control to
type="text"and back. - Set
autocompletetocurrent-passwordfor sign-in ornew-passwordfor sign-up and password changes so password managers fill or suggest the right value. - The mask character comes from the browser and cannot be changed to
*.
Textarea (type="textarea")
Use for multiline text entries (like comments or descriptions). You can define the default height via the rows prop, or let it default based on the size (s = 3, m = 5, l = 7). You can also lock the resize handle using resizable="false". The textarea uses the same border and state styles as the single-line field.
Composition
Labels
Use the label prop or the label slot on catnip-input. Optional label.action / label.suffix slots mirror the field-label patterns (for example a “Learn more” link). The component wires for / id automatically when you omit inputId, or respects your inputId when you set it explicitly for stable anchors.
For custom controls outside catnip-input, use standalone Field Label and wire html-for / id yourself.
There is no color prop; change appearance by theming tokens.
Supporting text
Do not manually place <catnip-field-supporting-text> under the field. Pass supporting-text. The input sets aria-describedby and intent styling.
Intents and Status
The intent prop controls the semantic border and supporting text color. Warning and success retain their semantic border when focused and use the standard primary focus ring. Danger uses the danger focus ring.
- Neutral (default): Standard input state.
- Warning: Warn about the current value (e.g. weak password).
- Danger: Validation errors. Sets
aria-invalid="true"on the native control. - Success: Confirm a valid state.
Best Practices
- Icon actions: If the right icon is clickable, set
right-icon-clickable="true"and provideright-icon-button-aria-label(except password, which sets labels for the visibility toggle). - Spacing: Avoid ad-hoc margins on inputs; use your layout’s flex or grid gaps between fields.