Skip to main content

Overview

HuxInput is a customizable text input component with consistent styling and extensive customization options. It provides a clean, modern text input with support for labels, hints, validation, icons, and different sizes while automatically adapting to light and dark themes.

Basic Usage

Simple Text Input

Simple input

Input with Managed Focus

Input with Icon

Input with icon

Input with Helper Text

Input with helper text

Input with Error State

Input with error

Properties

Core Properties

  • label - Optional field label text displayed above the input
  • hint - Placeholder text displayed inside the input when empty
  • controller - TextEditingController for managing input state
  • focusNode - FocusNode for managing input focus, useful with widgets such as RawAutocomplete
  • onChanged - Callback triggered when the input value changes
  • onSubmitted - Callback triggered when the user submits the input

Validation Properties

  • validator - Form validation function that returns error text or null
  • errorText - Custom error message (overrides validator output)
  • helperText - Helper text displayed below the input

Icon Properties

  • prefixIcon - Icon displayed at the beginning of the input
  • suffixIcon - Icon displayed at the end of the input
  • iconSize - Custom size for icons (default: 18px)

Behavior Properties

  • obscureText - Whether to hide the input text (for passwords)
  • enabled - Whether the input is interactive
  • maxLines - Maximum number of text lines (default: 1)
  • keyboardType - Type of keyboard to display
  • textInputAction - Action button for the keyboard

Layout Properties

  • width - Custom width (default: full width)

Styling & Dimensions

Fixed Dimensions

  • Height: 40px (consistent across all inputs)
  • Border Radius: 8px (rounded corners)
  • Font Size: 14px with 1.4 line height

Padding & Spacing

  • Horizontal Padding: 18px (left and right inside input)
  • Vertical Padding: 12px (top and bottom inside input)
  • Label Gap: 6px (space between label and input)

Icon Spacing

  • Icon Size: 18px (default, customizable)
  • Icon Outer Padding: 14px (space from edge to icon)
  • Icon Inner Padding: 4px (space between icon and text)

Color System

Border Colors

  • Default: HuxTokens.borderPrimary(context)
  • Focused: HuxTokens.primary(context) with 50% opacity
  • Error: HuxTokens.borderDestructive(context)
  • Focused Error: HuxTokens.textDestructive(context) with 2px width
  • Disabled: HuxTokens.borderSecondary(context)

Background Colors

  • Enabled: HuxTokens.surfacePrimary(context)
  • Disabled: HuxTokens.surfaceSecondary(context)

Text Colors

  • Input Text: Inherits from theme with 14px font size
  • Label Text: HuxTokens.textSecondary(context) with medium weight
  • Icon Color: HuxTokens.iconSecondary(context)

States

Enabled State

Enabled input
  • Fully interactive with normal styling
  • Responds to user input and focus

Focused State

Focused input
  • Enhanced border with primary color
  • Visual focus indicator for accessibility

Disabled State

Disabled input
  • Reduced opacity and non-interactive
  • Maintains visual consistency

Examples

Form Building

See HuxInput in action within forms

Validation Patterns

Learn form validation best practices