Start here
  • InstallationAdd Nelumbo to a shadcn project
  • ThemingBrand accent, neutrals, dynamic color
  • Biology componentsSequences, maps, plates and trees
  • katalyx.bio

    Search

    A search bar is a pill that holds a query; a search view is what it grows into, a docked panel on desktop and a full-screen view on phones, with recent searches, filters and results as a list. The command palette's text field is the same field.

    Install

    npx shadcn@latest add @nelumbo/search

    A full pill on surface-container-high with no border; it lifts a little on hover and focus. The leading slot holds the search icon or a navigation icon button, trailing slots take icon buttons and an avatar. The clear button springs in as soon as there is text.

    Type in the second bar and press Enter.

    Search view

    Click or tab into the field. The bar's pill morphs into a panel whose height springs with its content, and the leading icon turns into a back arrow. Type to filter, move with ArrowUp and ArrowDown (the highlighted row sits on a raised pill that springs between rows), Enter to open a result, Escape to close; the focus stays in the field. Shift+Delete forgets a recent search, and so does its close button.

    Recent searches

    Pick a result with the arrow keys and Enter.

    Phones

    Under 640px the same view opens full screen: the bar grows to fill the screen, the back arrow sits next to the input, the results fill the rest and the page behind stops scrolling. Tab stays inside it. Resize this window below 640px, or open the page on a phone, and open the search above.

    Back, Escape or picking a result folds the view back into the bar.

    In the command palette

    CommandInput is built from the same SearchField: a pill with the search icon and a clear button that springs in, with cmdk's own input inside (type search). Clearing empties cmdk's search whether it is controlled or not.

    import { SearchField, searchInputClasses } from "@/components/ui/search"​<SearchField size="sm" embedded hasValue={value.length > 0} onClear={() => setValue("")}>  <input className={searchInputClasses} value={value} onChange={(e) => setValue(e.target.value)} /></SearchField>

    Usage

    import {  SearchBar, SearchView, SearchViewFilters, SearchViewList,  SearchViewGroup, SearchViewItem, SearchViewEmpty,} from "@/components/ui/search"​<SearchBar label="Search the docs" value={q} onValueChange={setQ} onSubmit={run} />​<SearchView value={q} onValueChange={setQ} label="Search contacts" trailing={<IconButton label="Voice" icon="mic" />}>  <SearchViewFilters aria-label="Filter by type">    <FilterChip selected={people} onSelectedChange={setPeople}>People</FilterChip>  </SearchViewFilters>  <SearchViewList aria-label="Results">    <SearchViewGroup heading="Recent searches">      <SearchViewItem icon="history" onSelect={() => setQ("Maya")} onRemove={() => forget("Maya")}>        Maya      </SearchViewItem>    </SearchViewGroup>    {results.length === 0 && <SearchViewEmpty>No results</SearchViewEmpty>}  </SearchViewList></SearchView>

    Props

    PropTypeDefaultNotes
    SearchBar value / defaultValue / onValueChangestring / string / (value) => voidControlled or uncontrolled text
    SearchBar size"default" | "sm" | "xs""default"56px, 48px or 40px tall
    SearchBar leadingReactNode | nullsearch iconThe search icon, or an IconButton such as menu
    SearchBar trailing / avatarReactNodeIconButtons after the clear button; an Avatar at the end
    SearchBar labelstringplaceholderNames the search landmark and the input; give each bar its own
    SearchBar onSubmit / onClear(value) => void / () => voidEnter; after the clear button empties the field
    SearchView open / defaultOpen / onOpenChangeboolean / boolean / (open) => voidControlled or uncontrolled expansion
    SearchView value / onValueChange / onSubmitstring / (value) => voidQuery text; onSubmit runs on Enter with nothing highlighted
    SearchView leading / trailing / avatar / sizeLike SearchBar; the leading slot turns into a back arrow while open
    SearchView closeOnSelectbooleantrueClose after a result is picked
    SearchViewFiltersdiv propsA scrolling row for FilterChips; give it an aria-label
    SearchViewListdiv propsThe listbox, with the raised pill that springs between rows
    SearchViewGroup headingReactNodeA muted label above a run of options, no rule
    SearchViewItem onSelect / onRemove() => voidEnter or click; a remove button and Shift+Delete
    SearchViewItem icon / leading / description / meta / trailingNelumbo ListItem props
    SearchViewEmptyReactNodeShown when nothing matches, announced politely
    SearchField / searchFieldClassesThe shared pill field and its classes, used by Command