salla-search

Store search.

Store search. It shows a search box inside a modal, with live product results once three or more characters are typed (after a short pause), plus recent searches and popular searches before typing. Pressing Enter goes to the store's search results page. Use it in a theme header, either as a trigger (placeholder or inline) or as a bare modal that is opened from your own button.

Without placeholder or inline, only the modal is rendered. Open it by emitting the search::open event, for example salla.event.emit('search::open'). The component also emits these events through salla.event: salla-search::input.focused (first focus of the input), salla-search::product.clicked (payload { product, position }), salla-search::recommendation.clicked (payload { term, source }, where source is history, trending, suggestion or category) and Products Searched (payload { query, total }).

The input has a type of search. The back button and the remove button on each history item have an aria-label.

Use it

In HTML or JSX, use the tag <salla-search> with the Attribute names below. In React, the wrapper takes the Property names (camelCase).

import { SallaSearch } from '@salla.sa/twilight-components-react/search';

Client-only. On the server this wrapper renders a placeholder (a skeleton, or nothing), and the real component mounts in the browser. Do not rely on it for content that search engines must see.

Example

import { SallaSearch } from '@salla.sa/twilight-components-react/search';

export function Example() {
  return (
    <SallaSearch placeholder oval height={48} />
  );
}
import { SallaSearch } from '@salla.sa/twilight-components-react/search';

export function Example() {
  return (
    <>
      <button onClick={() => salla.event.emit('search::open')}>Search</button>
      <SallaSearch />
    </>
  );
}

Properties

PropertyAttributeDescriptionTypeDefault
heightheightHeight of the input, in pixels.number60
inlineinlineShows a read-only input that opens the search modal when it receives focus. Typing still happens in the modal's own input. Ignored when placeholder is set.booleanfalse
maxWordsmax-wordsMaximum number of words allowed in the input. Extra words are cut off as the customer types.number5
ovalovalGives the input fully rounded ends (border radius is half of height).booleanfalse
placeholderplaceholderShows a button styled like an input that opens the search modal when clicked. Takes priority over inline.booleanfalse
showActionshow-actionShows a search button at the end of the input. Clicking it runs the live search for the current term (it does not go to the results page).booleanfalse

Renders: <salla-search-product-card>, <salla-button>, <salla-modal>.

On this page