GitHub

search

A search input with a built-in icon and optional clear button. Handles the native browser cancel button, data-event binding, and debounce in one component. Use this instead of input({ type: 'search' }).

search({ name: 'q', label: 'Search', placeholder: 'Search products…' })

// With value, clear button, and hidden label:
search({
  name:        'q',
  label:       'Search',
  labelHidden: true,
  placeholder: 'Search…',
  value:       state.search,
  event:       'input:setSearch',
  debounce:    200,
  clearEvent:  'clearSearch',
})
PropTypeDefault
namestringField name and id base
labelstringLabel text — always provide for accessibility
labelHiddenbooleanfalseHides label visually; still read by screen readers
placeholderstring
valuestringCurrent value — controls clear button visibility
eventstringdata-event binding, e.g. 'input:setSearch'
debouncenumber200Debounce delay in ms — only applied when event is set
clearEventstringClick event for the × button — only shown when value is non-empty
disabledbooleanfalse
idstringOverride generated id
classstringExtra classes on the wrapper
attrsobject{}Extra attributes on the <input>