Officina UI
Components

SearchInput

Search field with a leading icon, clear button, and a debounced change callback.

SearchInput is a controlled text field with a leading search icon and a clear (×) button that appears once there is a value. Beyond the immediate onChange, it offers onDebouncedChange that fires after debounceMs (default 200ms) of inactivity — wire your actual query there to avoid firing a request on every keystroke. Disable the clear button with showClear={false}.

Example

Preview
import { SearchInput } from '@officina/ui';
import { useState } from 'react';

function Example() {
  const [query, setQuery] = useState('');
  return (
    <SearchInput
      value={query}
      onChange={setQuery}
      onDebouncedChange={(q) => runSearch(q)}
      placeholder="Search…"
    />
  );
}

API

PropTypeDefaultDescription
onChange*(value: string) => void—Called on every keystroke with the new query.
value*string—Current query string.
clearLabelstringClearAccessible label for the clear button.
debounceMsnumber200Debounce window for `onDebouncedChange`, in ms.
invalidboolean—Mark the field invalid for validation styling.
onDebouncedChange(value: string) => void—Called after `debounceMs` of inactivity — ideal for firing searches.
showClearbooleantrueShow a clear (×) button when there is a value.

On this page