Search

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

Usage

Search is an inline Material 3 contained search field with an optional projected results surface. Use it when users need to find content, navigate documentation, or filter a known collection. The implementation follows the contained Search bar specification and its interaction guidelines.

Search owns the query, clear action, submit event, input semantics, and inline results visibility. It does not implement docked or full-screen presentation. Compose it with SideSheet or another surface primitive when search should become modal; results are still projected by the consumer, so filtering and selection remain in application code.

Press Enter to submit

Material 3 anatomy

The component exposes the Material 3 contained Search bar anatomy through its public props: the decorative leading icon, supporting placeholder text, interactive trailing actions, and a clear action when the query is non-empty. The container uses the Search bar’s persistent filled surface, rounded shape, and touch-sized action buttons without a default shadow. When expanded, it reuses the same input and exposes a labeled projected results surface below the header without a baseline divider. Its focus indicator fades in briefly instead of appearing abruptly, and the results surface uses a restrained height/opacity reveal.

The inline results stay in normal page flow. A modal search can place the same Search inside SideSheet or another dialog/surface primitive; that surrounding primitive owns the modal presentation.

The result content is deliberately consumer-owned. This keeps the component usable with local filtering, remote search, recent searches, command palettes, and custom result designs while leaving loading, errors, empty states, and selection behavior in the feature that owns the data.

Compose Search with SideSheet

Search does not import or control SideSheet. The owning feature composes the two primitives when search needs a modal presentation. SideSheet owns the scrim, anchoring and width policy, portal, focus trap, inert background, scroll lock, and dismissal behavior; Search remains responsible for the field and its local results surface. Adapt the side sheet’s position and width classes for compact or expanded windows; Search does not need a breakpoint prop. The example uses a full-width compact panel and a constrained sm width to make that composition explicit.

The example shows both usages: an inline search and the same kind of search embedded in a modal side sheet.

Modal search is closed

Uncontrolled defaults

Use defaultQuery and defaultExpanded when the Search component should own its state. defaultExpanded controls the initial visibility of the projected local results surface; it does not open or close a surrounding SideSheet or dialog. This example still observes onQueryChange and onSearch so an application can react to user input without turning the field into a fully controlled component.

Current query: Material 3 · Submitted: not yet

Controlled and uncontrolled state

Use query with onQueryChange in React, [(query)] in Angular, or bind:query in Svelte, when the owning feature controls the query. defaultQuery initializes uncontrolled usage. The same pattern applies to expanded/onExpandedChange and defaultExpanded; those callbacks control only Search’s local results visibility. If Search is inside a modal surface, control that surface with its own open API.

Svelte renders projected results and trailing actions as snippets.

onSearch (React) or (searchSubmit) (Angular) receives the current query when the user presses Enter or invokes the search action from an input method editor.

Disabled, read-only, and clearable states

disabled prevents interaction and native input focus. readOnly keeps the value visible while preventing edits, and clearable={false} removes the automatic clear action without preventing the user from editing the query. The focus and blur callbacks remain available for integrating surrounding feature state.

Focus the read-only field

Leading icon and trailing actions

leadingIcon accepts the search icon, or another decorative icon, shown at the start of the field. It is not a button: clicking the field still focuses the input, while navigation/back/close belongs to the surrounding SideSheet or surface. For the right side, use trailingActions in React or project one or two udx-icon-button[search-trailing] controls in Angular. These are real interactive actions, not bare Icon definitions. Use them for additional search modes such as voice search, filters, settings, or another high-level action.

In Material 3 terminology, “icon” describes the visual element; when it triggers an interaction, its container is an IconButton. Search therefore receives action controls and leaves their inner Icon to IconButton.

Material 3 allows one or two trailing icons or icon buttons. Search’s built-in clear action counts as one while it is visible, so combine it with at most one custom trailing action. Set clearable={false} when two custom trailing actions must remain visible. Modal or side-sheet close actions remain owned by the surrounding surface.

Results, empty, loading, and error states

Search does not fetch or filter data itself. Update the projected content from the owning feature and expose an appropriate empty, loading, or error state. When the expanded state changes, Search animates this inline surface with a short Anime.js height/opacity transition; the transition is skipped when reduced motion is requested. When the local results surface is expanded, a pointer outside Search closes it; modal dismissal remains owned by the surrounding SideSheet or surface. When Search is inside a SideSheet, the side sheet owns the modal surface while Search continues to own the labeled local results surface inside it. Selectable results should use role="option", aria-selected, and tabIndex={-1} (or tabindex="-1" in Angular); a status message can use aria-live when its content changes.

Consumer-managed state: Results available

Rich result content with resultsRole="dialog"

Use resultsRole="dialog" when the expanded surface contains actions or a rich layout rather than a list of selectable options. The component provides the labeled results surface, but the consumer remains responsible for the dialog content’s focus order, keyboard behavior, and action semantics.

No action selected

Native form integration and input attributes

The native search input forwards id, name, required, maxLength, autoComplete, inputMode, spellCheck, and the other standard input attributes. onSearch/(searchSubmit) handles Enter from the search field; the surrounding form can still be submitted with a separate native submit button.

Nothing submitted

Auto-focus and focus events

Set autoFocus only when the feature intentionally owns the initial focus, such as after opening a search panel. onFocus/onBlur in React and (focused)/(blurred) in Angular expose native focus transitions for status or surrounding UI updates. When a modal surface is used, let that surface own the panel focus lifecycle and use autoFocus only when it is compatible with that lifecycle. The example mounts the component from a button so the focus behavior can be tested without stealing focus on page load.

Focus events: 0 · Blur events: 0

Results and keyboard behavior

Project suggestions or results as children. With the default resultsRole="listbox", give selectable children role="option", aria-selected, and tabIndex={-1} (or tabindex="-1" in Angular). Search shares the menu navigation model: Arrow Down/Up opens the local results surface and moves focus to the first or last option, Enter submits the query, and Escape closes the expanded local results surface and restores focus to the input. A surrounding modal surface handles its own Escape and dismissal behavior.

Set resultsRole="dialog" when the projected content is a richer search view rather than a list of options. In that mode, the consumer owns the dialog content semantics and focus management inside it.

Accessibility

label is required and names the native input[type="search"]. The leading icon is decorative and hidden from assistive technology; interactive actions belong to the clear control or trailing buttons. When results are present, the input exposes the combobox relationship to the labeled results surface. The clear action has a configurable accessible name through clearLabel, and Search keeps the Material 3 48 px touch target for its field actions. If Search is composed inside SideSheet, the side sheet owns the modal dialog semantics, close action, focus trap, and background inertness.

The input forwards native form attributes such as name, required, readOnly, autoComplete, and inputMode. The component does not filter or announce result data itself: applications should update the projected content and provide an appropriate empty state when no match exists.