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.
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
Choose something else when
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
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.
| 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 | Use value to supply rendered state. Update it through the documented callback or native event handler. For browser-owned initial values, use defaultValue instead. |
| DOM target | sx 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
| 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 |