Search
A search bar that opens a full-screen view on phones and a docked view on larger windows, and an app bar with search.
import { SearchBar, SearchAppBar } from '@windmorph/react';Purpose
A SearchBar is a 56px pill that expands into a search view holding suggestions or results. With view="docked" it opens a dropdown below the bar over a scrim; with view="full-screen" it grows to fill the window. The default, view="auto", is full screen on compact windows (below 600px wide) and docked on larger ones, as M3 recommends. It is controlled with value / onChange, and onSubmit fires on Enter.
leadingIcon and trailingIcon can be functions of { expanded, collapse, view }, so a back or clear button appears while the view is open. The trailing slot holds one or two icon buttons, or an avatar (an img, drawn at 30px) and one icon button; two buttons sit 8px apart, so their 48px targets don't overlap. Icon buttons in either slot take its colour and its icon colour token. textAlign="center" centres the collapsed text. SearchAppBar (Compose's AppBarWithSearch) wraps a search bar in a top bar with a navigationIcon, actions and scrollBehavior.
To filter what's already on the screen, with no view to open, use a SearchField: the same pill as a search box, filling its container.
When not to use
To filter content in place use a Search field; for a search inside a form use a Text field.
See also
- Search on m3.material.io: Material's own guidelines, with anatomy and specs.
- Search field: The search bar's 56px pill as a search box that filters a page, a list or a table in place, with a clear button. It never opens a search view.
- Top app bar: A header with the screen title and actions, in three sizes, with scroll behaviour.
- Text field: Filled or outlined text input with a floating label, icons, affixes, counter, error icon and a text area.