Navigated to /docs/ui/components/search-input

SearchInput

Search input primitive with consistent control sizing.

Preview

A live, theme-aware example rendered with the published component.

Loading preview…

Import

Import from the focused entry point below, or use the same named export from @tavojs/ui. Both are public APIs; measure the built application when comparing their bundle cost.

TSX
tsximport { SearchInput } from "@tavojs/ui/search-input";

The component import loads compiled component CSS. Enable tavoUi() for your project theme variables, or import @tavojs/ui/theme.css once for the package default theme. The equivalent CSS-safe component alias is @tavojs/ui/css/search-input.

When to use

Use it when

Use `SearchInput` for labeled search and filtering fields. It keeps query state, filtering, debouncing, and result rendering in the consuming application

Choose something else when

Avoid SearchInput when wrapping controls without labels or accessible names.

Examples

These examples include imports and local state where interaction requires it. Render the exported component in a page after completing UI installation. Demo state stays in the mounted component; connect file handling, persistence, and data loading to your application as needed.

SearchInput example

TSXCreate: src/components/examples/SearchInputExample1.tsx
tsximport { createTavo } from "@tavojs/core";
import { SearchInput } from "@tavojs/ui/search-input";
import { Field, Text } from "@tavojs/ui";

type State = { query: string };

export const SearchInputExample1 = createTavo<Record<string, never>, State>({
  model: () => ({ query: "" }),
  view: ({ state, model }) => (
    <>
      <Field id="resource-search" label="Search resources">
        <SearchInput
          value={state.query}
          placeholder="Name or category"
          clearable
          onInput={(event) => model.set("query", event.currentTarget.value)}
          onClear={() => model.set("query", "")}
        />
      </Field>
      <Text>{state.query ? `Filtering by: ${state.query}` : "Showing all resources"}</Text>
    </>
  )
});

Common props and defaults

A curated starting point. The complete TypeScript API below includes additional props and compound member contracts.

PropTypeDefaultDescription
classNamestring

Optional class hook applied to the public root element owned by the component.
sizeSize

Configures size for this component.
valuestring

Configures value for this component.
defaultValuestring

Configures defaultValue for this component.
clearableboolean

Configures clearable for this component.
clearLabelstring

Configures clearLabel for this component.
loadingboolean

Configures loading for this component.
leadingChild

Configures leading for this component.
trailingChild

Configures trailing for this component.

Complete TypeScript API

Import from @tavojs/ui/search-input. Published exports: SearchInput, SearchInputProps.

SearchInputProps

PropertyTypeRequiredDescription
classNamestring

No

Optional class hook applied to the public root element owned by the component.

inputClassNamestring

No

Inherited inputClassName attribute accepted by SearchInput.

sizeSize

No

Configures size for this component.

valuestring

No

Configures value for this component.

defaultValuestring

No

Configures defaultValue for this component.

namestring

No

Inherited name attribute accepted by SearchInput.

placeholderstring

No

Inherited placeholder attribute accepted by SearchInput.

autoCompletestring

No

Inherited autoComplete attribute accepted by SearchInput.

inputModestring

No

Inherited inputMode attribute accepted by SearchInput.

requiredboolean

No

Inherited required attribute accepted by SearchInput.

readOnlyboolean

No

Inherited readOnly attribute accepted by SearchInput.

minLengthnumber

No

Inherited minLength attribute accepted by SearchInput.

maxLengthnumber

No

Inherited maxLength attribute accepted by SearchInput.

patternstring

No

Inherited pattern attribute accepted by SearchInput.

typenever

No

Inherited type attribute accepted by SearchInput.

clearableboolean

No

Configures clearable for this component.

clearLabelstring

No

Configures clearLabel for this component.

loadingboolean

No

Configures loading for this component.

leadingChild

No

Configures leading for this component.

trailingChild

No

Configures trailing for this component.

onClear() => void

No

Inherited onClear attribute accepted by SearchInput.

onChangeValueChangeHandler<HTMLInputElement>

No

Inherited onChange attribute accepted by SearchInput.

onInputValueChangeHandler<HTMLInputElement>

No

Inherited onInput attribute accepted by SearchInput.

State ownership and DOM target

ConcernContract
StateUse value to supply rendered state. Update it through the documented callback or native event handler. For browser-owned initial values, use defaultValue instead.
DOM targetsx and className style the wrapper. Native input attributes and input events target the owned input control.

Anatomy and related components

This component exposes one public component root rather than a compound member API.

Limitations

Avoid SearchInput when wrapping controls without labels or accessible names.

Use only the documented props, entry points, and compound members. Internal DOM nesting and CSS class names can change without becoming part of the public component contract.

Accessibility

Pair the control with `Field`, a visible label, or `aria-label`. Loading sets `aria-busy` on the native input, and the clear action uses `clearLabel` as its accessible name.

  • Pair the control with `Field`, a visible label, or `aria-label`. Loading sets `aria-busy` on the native input, and the clear action uses `clearLabel` as its accessible name.

Component status

ContractCurrent value
Maturitystable
Categoryforms
Component import@tavojs/ui/search-input
Explicit CSS import@tavojs/ui/css/search-input
PreviewInteractive preview available on this page