Skip to main content

Configure the following properties on the SearchField component.

Anchor to disabled
disabled
boolean
Default: false

Whether the field is disabled, preventing user interaction. Use when the field is temporarily unavailable due to application state, permissions, or dependencies.

string

A unique identifier for the element used for targeting with CSS, JavaScript, or accessibility features.

Anchor to placeholder
placeholder
string

A short hint that provides guidance about the expected value of the field.

Anchor to value
value
string

The current search query text entered in the field. An empty string means no search query is entered.

The search field component provides event callbacks for handling user interactions. Learn more about handling events.

(event: <"s-search-field">) => void

Called when the element loses focus.

Anchor to change
change
(event: <"s-search-field">) => void

Called after editing completes, typically on blur.

Anchor to focus
focus
(event: <"s-search-field">) => void

Called when the element receives focus.

Anchor to input
input
(event: <"s-search-field">) => void

Called when the user makes any changes in the field.


Anchor to Enable search with a search fieldEnable search with a search field

Enable search functionality using a search field component. This example shows a basic search field with placeholder text.

Enable search with a search field

Enable search functionality using a search field component. This example shows a basic search field with placeholder text.

Enable search with a search field

<s-search-field placeholder="Search" />

Anchor to Handle search input eventsHandle search input events

Subscribe to search input events to respond when merchants enter search terms. This example demonstrates handling onChange and onInput events for real-time search functionality, debounced filtering, or triggering search API calls as merchants type their queries.

Handle search input events

<s-search-field
placeholder="Search products..."
value=""
onInput={(event) => console.log('Input:', event.currentTarget.value)}
onChange={(event) => console.log('Change:', event.currentTarget.value)}
onFocus={(event) => console.log('Search focused')}
onBlur={(event) => console.log('Search blurred')}
/>

  • Use for inline search and filtering: Choose search field for filtering within specific sections or lists, not for global navigation or complex multi-step searches.
  • Follow placeholder pattern: Use "Search {items}" format like "Search products" or "Search customers" to clarify scope.
  • Choose the right event: Use input for real-time filtering as users type. Use change for expensive operations that should wait until typing completes.
  • Handle empty values: When the field is cleared, reset filters or show all items appropriately.

Was this page helpful?