Skip to main content
The Input component provides a flexible text input field with support for labels, icons, validation states, and various input types.

Basic usage

<flx-input
  label="Username"
  placeholder="Enter your username"
  [(ngModel)]="username">
</flx-input>

Properties

label
string
Label text displayed above the input field
placeholder
string
Placeholder text shown when input is empty
value
string
The current value of the input field
type
string
default:"text"
HTML input type: text, email, password, number, tel, url
disabled
boolean
default:"false"
Disables the input field
readonly
boolean
default:"false"
Makes the input read-only
required
boolean
default:"false"
Marks the field as required
error
boolean | string
default:"false"
Shows error state. Pass a string to display error message
helperText
string
Helper text displayed below the input
prefixIcon
string
Icon displayed at the start of the input
suffixIcon
string
Icon displayed at the end of the input
maxLength
number
Maximum number of characters allowed
autocomplete
string
Browser autocomplete hint

Events

valueChange
EventEmitter<string>
Emitted when the input value changes
blur
EventEmitter<FocusEvent>
Emitted when the input loses focus
focus
EventEmitter<FocusEvent>
Emitted when the input receives focus

Examples

<flx-input
  label="Email"
  type="email"
  prefixIcon="mail"
  placeholder="you@example.com"
  [(ngModel)]="email">
</flx-input>

<flx-input
  label="Search"
  prefixIcon="search"
  suffixIcon="x"
  placeholder="Search..."
  [(ngModel)]="searchQuery">
</flx-input>

Styling

Customize the Input component using CSS custom properties:
flx-input {
  --flx-input-height: 40px;
  --flx-input-padding: 0 12px;
  --flx-input-border-radius: 4px;
  --flx-input-border-color: #d1d5db;
  --flx-input-focus-border-color: #3b82f6;
  --flx-input-error-border-color: #ef4444;
  --flx-input-background: #ffffff;
  --flx-input-text-color: #111827;
  --flx-input-placeholder-color: #9ca3af;
}

Accessibility

The Input component automatically handles:
  • Proper label association with for and id attributes
  • aria-required for required fields
  • aria-invalid for fields with errors
  • aria-describedby for helper text and error messages
Always provide a descriptive label for screen reader users. If you need a visually hidden label, use CSS to hide it while keeping it accessible.

Best practices

  • Use appropriate input types for better mobile keyboard support
  • Provide clear validation feedback with error messages
  • Use helper text to guide users on input requirements
  • Consider using autocomplete attributes for common fields
  • Set reasonable maxLength limits for text inputs
  • Use prefix/suffix icons to provide visual context

Build docs developers (and LLMs) love