Search

Search lets people enter a keyword or phrase to get relevant information.

Props

React props
NameTypeRequiredDefaultDescription
leadingIconIconNoDecorative icon shown at the leading edge; the search icon is used by default.
classNamestring | Partial<Record<"container" | "search" | "input" | "stateLayer" | "inputField" | "leadingIcon" | "trailingActions" | "clearButton" | "results", string>> | ClassNameComponent<...>NoRoot classes (string), static element classes (object), or state-aware element classes (function).
autoFocusbooleanNoFocuses the input once, on mount.
idstringNoId of the search input. Auto-generated if not provided.
spellCheckbooleanNotrueNative spell-check preference.
inputModeSearchInputModeNoNative input mode hint.
labelstringYesAccessible name for the native search input.
querystringNoControlled query. Providing it makes the search controlled for its lifetime.
defaultQuerystringNo''Initial query for uncontrolled usage.
onQueryChange(query: string) => voidNoCalled once for each accepted query transition.
expandedbooleanNoControlled expanded state. Providing it makes the state controlled for its lifetime.
defaultExpandedbooleanNofalseInitial expanded state for uncontrolled usage.
onExpandedChange(expanded: boolean) => voidNoCalled once for each accepted expanded-state transition.
onSearch(query: string) => voidNoCalled when the user submits the current query with the search action.
placeholderstringNo'Search'Hint displayed while the query is empty.
disabledbooleanNofalsePrevents query editing and activation.
clearablebooleanNotrueClears the query when the clear action is activated.
namestringNoNative form name forwarded to the search input.
autoCompletestringNo'off'Native autocomplete hint.
maxLengthnumberNoNative maximum query length.
minLengthnumberNoNative minimum query length.
requiredbooleanNoRequires a non-empty query when the input participates in a form.
readOnlybooleanNoPrevents editing while preserving the search value and semantics.
resultsRoleSearchResultsRoleNo'listbox'Role used by the projected results surface.
resultsLabelstringNo'Search suggestions'Accessible name for the projected results surface.
clearLabelstringNo'Clear search'Accessible name of the clear action.
trailingActionsReactNodeNoInteractive trailing controls, normally one or two `IconButton` instances.