Skip to main content
Neighborhood Design System v5.1.0

Search

Ready

A search input component that allows users to enter and submit search queries.

Preview

Open in Storybook (opens in new tab)

Code

Install
npm install @fbin-web/neighborhood-core
Import
import { NbhdSearch } from '@fbin-web/neighborhood-core';
Usage
<nbhd-search
  search-value="magic"
  aria-label="Search"
  placeholder="Search"
  surface="none">
</nbhd-search>

Usage

  • Search composes an nbhd-input with clear and submit buttons.

Properties

PropertyAttributeTypeDefaultDescription
searchValuesearch-valuestring—The value of the search input.
autofocusautofocusbooleanfalseWhether the search input should automatically receive focus.
surfacesurfacenoneprimarysecondaryinverseinverse-secondarynoneSets the surface color treatment for the search.
ariaLabelaria-labelstringSearchAccessible name of the search input.
landmarkLabellandmark-labelstringSiteAccessible name of the search landmark, announced as "
clearLabelclear-labelstringClear searchAccessible name of the clear button.
submitLabelsubmit-labelstringSearchAccessible name of the submit button.
placeholderplaceholderstringSearchThe placeholder text for the search input.
autosuggestautosuggeststring—ID of the `nbhd-autosuggest` that shows suggestions for this input. Makes the input a combobox: `aria-expanded` follows the autosuggest, ArrowDown moves into the results, and Escape closes them (a second Escape clears the input). The autosuggest must be in the same document or shadow root.

Events

NameDescriptionEvent Detail
nbhd-search-inputEmitted when the search input value changes or is cleared.{ value: string }
nbhd-search-submitEmitted when the search is submitted via button click or Enter key.{ value: string }

CSS Parts

NameDescription
baseThe root search container div.
wrapperThe wrapper div containing the input and buttons.
search-inputThe search input element.
clear-buttonThe button to clear the search input (conditionally rendered).
submit-buttonThe button to submit the search.
nbhd-search::part(base) {
  /* your styles */
}

CSS Properties

Set these on nbhd-search or an ancestor to override the defaults. Token is the design token a default comes from and Value is what it resolves to in core Neighborhood; brands may override them. Properties that adapt to surface follow the light or inverse surface they sit on until you set them.

PropertyTokenValueDescription Copy
--nbhd-search-alignItems—center—
--nbhd-search-button-clear-insetInlineEnd--nbhd-space-1248px—
--nbhd-search-button-fontSize--nbhd-typography-body-fontSize1rem—
--nbhd-search-button-icon-size--nbhd-size-icon-md20px—
--nbhd-search-button-insetBlockStart—50%—
--nbhd-search-button-minSize--nbhd-size-target-min24pxMinimum clear/submit target (WCAG 2.5.8); the icon keeps its own size.
--nbhd-search-button-position—absolute—
--nbhd-search-button-submit-insetInlineEnd--nbhd-space-312px—
--nbhd-search-button-transform—translateY(-50%)—
--nbhd-search-button-zIndex--nbhd-z-11—
--nbhd-search-display—flex—
--nbhd-search-input-paddingInline--nbhd-space-3 --nbhd-space-2212px 88px—
--nbhd-search-justifyContent—center—
--nbhd-search-minInlineSize--nbhd-size-container-min320px—
--nbhd-search-paddingBlock--nbhd-space-28px—
--nbhd-search-paddingInline--nbhd-space-28px—

Dependencies

Child components <nbhd-search> renders internally. Import them too when you tree-shake.

Esc
↑ ↓ to move↵ to open