SearchInput
Search input primitive with consistent control sizing.
Preview
A live, theme-aware example rendered with the published component.
Loading preview…
Import
Import the component from its dedicated entry point to keep the dependency and generated bundle explicit.
tsximport { SearchInput } from "@tavojs/ui/search-input";Normal Tavo.js applications load component styles through the Tavo.js UI plugin. If the application manages component CSS manually, also import @tavojs/ui/css/search-input.
When to use
Use it when
Choose something else when
Examples
SearchInput example
tsximport { SearchInput } from "@tavojs/ui/search-input";
import { Field } from "@tavojs/ui";
export function SearchInputExample1() {
let query = "";
const isSearching = false;
const setQuery = (nextQuery: string) => {
query = nextQuery;
};
return (
<>
<Field label="Search resources">
<SearchInput
value={query}
placeholder="Name or category"
clearable
loading={isSearching}
onInput={(event) => setQuery(event.currentTarget.value)}
onClear={() => setQuery("")}
/>
</Field>
</>
);
}Common props and defaults
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Optional class hook applied to the public root element owned by the component. |
size | Size | — | Configures size for this component. |
value | string | — | Configures value for this component. |
defaultValue | string | — | Configures defaultValue for this component. |
clearable | boolean | — | Configures clearable for this component. |
clearLabel | string | — | Configures clearLabel for this component. |
loading | boolean | — | Configures loading for this component. |
leading | Child | — | Configures leading for this component. |
trailing | Child | — | Configures trailing for this component. |
Complete TypeScript API
Import from @tavojs/ui/search-input. Published exports: SearchInput, SearchInputProps.
SearchInputProps
| Property | Type | Required | Description |
|---|---|---|---|
className | string | No | Optional class hook applied to the public root element owned by the component. |
inputClassName | string | No | Inherited inputClassName attribute accepted by SearchInput. |
size | Size | No | Configures size for this component. |
value | string | No | Configures value for this component. |
defaultValue | string | No | Configures defaultValue for this component. |
name | string | No | Inherited name attribute accepted by SearchInput. |
placeholder | string | No | Inherited placeholder attribute accepted by SearchInput. |
autoComplete | string | No | Inherited autoComplete attribute accepted by SearchInput. |
inputMode | string | No | Inherited inputMode attribute accepted by SearchInput. |
required | boolean | No | Inherited required attribute accepted by SearchInput. |
readOnly | boolean | No | Inherited readOnly attribute accepted by SearchInput. |
minLength | number | No | Inherited minLength attribute accepted by SearchInput. |
maxLength | number | No | Inherited maxLength attribute accepted by SearchInput. |
pattern | string | No | Inherited pattern attribute accepted by SearchInput. |
type | never | No | Inherited type attribute accepted by SearchInput. |
clearable | boolean | No | Configures clearable for this component. |
clearLabel | string | No | Configures clearLabel for this component. |
loading | boolean | No | Configures loading for this component. |
leading | Child | No | Configures leading for this component. |
trailing | Child | No | Configures trailing for this component. |
onClear | () => void | No | Inherited onClear attribute accepted by SearchInput. |
onChange | ValueChangeHandler<HTMLInputElement> | No | Inherited onChange attribute accepted by SearchInput. |
onInput | ValueChangeHandler<HTMLInputElement> | No | Inherited onInput attribute accepted by SearchInput. |
State ownership and DOM target
| Concern | Contract |
|---|---|
| State | Application controlled through value and the matching callback. |
| DOM target | Native input attributes target the owned form control; wrapper-specific props stay on the documented component root. |
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
| Contract | Current value |
|---|---|
| Maturity | stable |
| Category | forms |
| Component import | @tavojs/ui/search-input |
| Explicit CSS import | @tavojs/ui/css/search-input |
| Preview | Interactive preview available on this page |