Forms

SearchInput

A fully accessible autocomplete/combobox component following WAI-ARIA 1.2 pattern. Supports async search, keyboard navigation, grouped options, and custom rendering. Perfect for patient, provider, and payer search workflows.

Basic Usage

Type to search and select from available options. Includes debounced search, keyboard navigation, and clear functionality.

With Custom Icon

Replace the default search icon with a contextual icon for better visual communication.

Grouped Options

Organize options into logical groups for better discoverability. Useful for provider directories with specialties.

Async Search with Loading

Handle asynchronous search with loading states. Results are fetched from an API as you type.

Custom Option Rendering

Use snippets to customize how options are displayed. Add badges, icons, or additional metadata.

Validation States

Display validation feedback with error and success states. Use validateOnMount to show state immediately.

Size Variants

Choose appropriate sizes based on form density and visual hierarchy.

Custom Empty State

Provide helpful empty states when no results are found.

Props

PropTypeDefaultDescription
id stringUnique identifier for the input
name stringForm field name
label *stringLabel text for the input
value string''Current search query (bindable)
selected SearchOption | nullCurrently selected option (bindable)
placeholder string'Search...'Placeholder text
options SearchOption[] | SearchOptionGroup[][]Options to display in dropdown
required booleanfalseWhether the field is required
disabled booleanfalseWhether the field is disabled
readonly booleanfalseWhether the field is read-only
error stringError message to display
hint stringHint text to display below the input
successMessage stringSuccess message when valid
size 'sm' | 'md' | 'lg''md'Size of the input
hideLabel booleanfalseHide label visually (still accessible)
loading booleanfalseShow loading spinner during search
emptyMessage string'No results found'Message when no results
minSearchLength number1Minimum characters before search
debounceMs number300Debounce delay in milliseconds
clearable booleantrueShow clear button when has value
openOnFocus booleanfalseOpen dropdown on focus
autoSelect booleanfalseAuto-select first option
allowFreeText booleanfalseAllow values not from options
iconLeft SnippetCustom left icon (default: Search icon)
optionContent Snippet<[SearchOption]>Custom option rendering
emptyContent SnippetCustom empty state content
loadingContent SnippetCustom loading content
onsearch (query: string) => voidCalled when search query changes (debounced)
onselect (option: SearchOption) => voidCalled when an option is selected
onclear () => voidCalled when selection is cleared
testId stringTest ID for e2e testing
validateOnMount booleanfalseShow validation state immediately

Types

interface SearchOption {
  value: string;           // Unique identifier
  label: string;           // Display text
  disabled?: boolean;      // Option disabled state
  description?: string;    // Secondary text
  icon?: Component;        // Optional icon component
  metadata?: Record<string, unknown>; // Custom data
}

interface SearchOptionGroup {
  label: string;           // Group header
  options: SearchOption[]; // Options in this group
}

Keyboard Navigation

KeyAction
Open dropdown / Move to next option
Move to previous option
EnterSelect highlighted option
EscapeClose dropdown
HomeMove to first option
EndMove to last option
TabClose dropdown and move focus

Healthcare Best Practices

  • • Always include patient identifiers (MRN, DOB) in search results to prevent misidentification
  • • Use debounced search to reduce API calls and improve performance with large datasets
  • • Group providers by specialty or location for easier navigation in large directories
  • • Provide clear empty states with actionable next steps (e.g., "Add new patient")
  • • Mark disabled options clearly when providers aren't accepting new patients or are unavailable
  • • Implement proper validation for required selections before form submission
  • • Ensure all interactions work with keyboard only for accessibility compliance
  • • Consider using async search for large datasets to avoid loading all data upfront

Accessibility Features

  • WAI-ARIA Combobox Pattern: Full implementation of ARIA 1.2 combobox with listbox popup
  • Keyboard Navigation: Complete arrow key, Home, End, Enter, and Escape support
  • Screen Reader Support: Announces result count, selected items, and state changes
  • Focus Management: Maintains focus in input while navigating options via aria-activedescendant
  • Reduced Motion: Respects user's motion preferences for animations
  • Clear Labels: Proper labeling and descriptions for all interactive elements