Search

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

Props

React props
NameTypeRequiredDefaultDescription
leadingIconIconNo—Decorative icon shown in the leading 48 px slot; the search icon is used by default.
classNamestring | Partial<Record<"container" | "search" | "input" | "stateLayer" | "inputField" | "leadingIcon" | "trailingActions" | "avatarSlot" | "clearButton" | "results", string>> | ClassNameComponent<...>No—Root classes (string), static element classes (object), or state-aware element classes (function).
autoFocusbooleanNo—Focuses the input once, on mount.
idstringNo—Id of the search input. Auto-generated if not provided.
spellCheckbooleanNotrueNative spell-check preference.
inputModeSearchInputModeNo—Native input mode hint.
labelstringYes—Accessible name for the native search input.
querystringNo—Controlled query. Providing it makes the search controlled for its lifetime.
defaultQuerystringNo''Initial query for uncontrolled usage.
onQueryChange(query: string) => voidNo—Called once for each accepted query transition.
expandedbooleanNo—Controlled expanded state. Providing it makes the state controlled for its lifetime.
defaultExpandedbooleanNofalseInitial expanded state for uncontrolled usage.
onExpandedChange(expanded: boolean) => voidNo—Called once for each accepted expanded-state transition.
onSearch(query: string) => voidNo—Called 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.
namestringNo—Native form name forwarded to the search input.
autoCompletestringNo'off'Native autocomplete hint.
maxLengthnumberNo—Native maximum query length.
minLengthnumberNo—Native minimum query length.
requiredbooleanNo—Requires a non-empty query when the input participates in a form.
readOnlybooleanNo—Prevents 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.
trailingActionsReactNodeNo—Interactive trailing controls, normally one or two `IconButton` instances.
avatarReactNodeNo—Optional non-interactive avatar rendered in the trailing avatar slot.