Types
The types of @poltura/theme-sdk/search.
Ezen az oldalon
import { … } from '@poltura/theme-sdk/search';SearchState
The storefront search: the query, live results, suggestions and the actions that drive them.
queryrequiredstringWhat the shopper typed.
setQueryrequired(query: string) => voidUpdates the query; results follow after a short pause.
debouncedQueryrequiredstringThe query results are for, after the pause.
hasQueryrequiredbooleanWhether the query is long enough to search, two characters or more.
resultsrequiredreadonly ProductCard[]The matching products.
totalrequirednumber | nullHow many products match, or null before the first answer.
isFetchingrequiredbooleanWhether results are loading.
suggestionsrequiredreadonly SearchSuggestion[]Popular searches and matching categories.
featuredrequiredreadonly ProductCard[]The merchant's featured products, in order.
categoriesrequiredreadonly SearchSuggestion[]The categories whose name matches the query.
collectionsrequiredreadonly SearchSuggestion[]The collections whose name matches the query.
pagesrequiredreadonly SearchSuggestion[]The store's pages whose title matches the query.
recentrequiredreadonly SearchSuggestion[]What the shopper searched for on this device, newest first.
resultsHrefrequiredstringThe full results page for the query.
submitrequired() => voidOpens the full results page for the query.
clearrequired() => voidEmpties the query.
SearchSuggestion
A suggestion shown before or while the shopper types: a popular or recent search, or a matching category, collection or page.
kindrequired'query' | 'recent' | 'category' | 'collection' | 'page'Whether it is a popular or recent search, or a category, collection or page.
labelrequiredstringThe suggestion's text in the page language.
hrefrequiredstringWhere choosing it goes.
iconIconValue | nullA category's icon, drawn with `Icon`; null or absent otherwise.
SearchOptions
Options of useSearch.
limitnumberMost products to load as results; defaults to 6.
popularSearchesreadonly string[]Popular searches offered before the shopper types, in order.
featuredCollectionIdstringThe collection whose products are offered as featured before the shopper types.
SearchInputProps
Props of SearchInput.
valuerequiredstringWhat the field shows.
onChangerequired(value: string) => voidCalled with the new text as the shopper types.
onSubmitrequired() => voidCalled when the shopper presses Enter without a highlighted option.
placeholderstringShown while the field is empty.
classNamestringClasses added to the field's form.
SearchResultsProps
Props of SearchResults.
staterequiredSearchStateThe search whose results to list.
onNavigate() => voidCalled when the shopper opens a result, such as to close a dialog.
classNamestringClasses added to the list.
SearchSuggestionsProps
Props of SearchSuggestions.
itemsrequiredreadonly SearchSuggestion[]Popular searches and categories to offer.
featuredrequiredreadonly ProductCard[]Featured products to offer below them.
onPick(suggestion: SearchSuggestion) => voidCalled when the shopper picks a suggestion; without it every suggestion is a link.
onNavigate() => voidCalled when the shopper opens a featured product.
classNamestringClasses added to the list.
SearchDialogProps
Props of SearchDialog.
labelrequiredstringNames the dialog and its icon button for assistive technology.
openbooleanWhether the dialog is open; leave unset to let the button control it.
onOpenChange(open: boolean) => voidCalled when the dialog opens or closes.
childrenrequiredReactNodeWhat the dialog holds, usually the field and the results.
classNamestringClasses added to the dialog.
SearchGroupKind
A result group of the search dropdown, as the element type the merchant adds under a search block.
type SearchGroupKind = 'products' | 'categories' | 'collections' | 'pages' | 'popular' | 'recent' | 'view-all' | 'empty'SearchGroup
One result group of the search dropdown, in the order the dropdown lists it.
idrequiredstringThe group's block id.
kindrequiredSearchGroupKindWhat the group lists.
headingrequiredstringThe group's heading; empty shows the platform heading.
limitrequirednumberMost items the group lists.
imagerequiredbooleanWhether product rows show their image.
pricerequiredbooleanWhether product rows show their price.
badgerequiredbooleanWhether product rows show the merchant's badge.
layoutrequired'list' | 'grid'Rows under each other, or a grid.
columnsrequired2 | 3The grid's columns.
textrequiredstringThe text of a view-all link or a no-results note; empty shows the platform text.
suggestionsrequiredbooleanWhether a no-results note offers the popular searches.
attrsElementAttrsThe group block's attributes, spread on the group's root.
SearchDropdown
How the search dropdown is drawn.
width'input' | 'wide' | 'full'As wide as the field, a wide panel, or the page's full width.
schemestringThe colour scheme the dropdown draws in; unset keeps the page's.
radiusnumberCorner radius in pixels; unset keeps the theme's corners.
shadow'none' | 'soft' | 'strong'The dropdown's shadow; unset draws the soft overlay shadow.
phone'anchored' | 'sheet'On phones, open under the field or as a sheet from the bottom of the screen.
SearchComboboxProps
Props of SearchCombobox.
limitnumberMost products to load as results; defaults to 6.
popularSearchesreadonly string[]Popular searches offered before the shopper types, in order.
featuredCollectionIdstringThe collection whose products are offered as featured before the shopper types.
placeholderstringShown while the field is empty.
floatingbooleanThe suggestions and results float in a popover under the field; otherwise they list below it.
onNavigate() => voidCalled when the shopper opens a result or a featured product, such as to close a dialog.
groupsreadonly SearchGroup[]The dropdown's result groups in order; unset lists popular searches, products and the no-results note.
dropdownSearchDropdownThe dropdown's width, colour scheme, corners, shadow and phone presentation.
previewbooleanHolds the dropdown open with sample results, as the editor shows a selected search block.
HeaderSearchProps
Props of HeaderSearch.
limitnumberMost products to load as results; defaults to 6.
popularSearchesreadonly string[]Popular searches offered before the shopper types, in order.
featuredCollectionIdstringThe collection whose products are offered as featured before the shopper types.
variant'inline' | 'popover' | 'dialog'A field with its results in a popover under it, an icon that opens a popover, or an icon that opens a dialog.
placeholderstringShown while the field is empty.
classNamestringClasses added to the field or the icon button.
attrsElementAttrsA block's attributes, spread on the search's root when it draws the block itself.
groupsreadonly SearchGroup[]The dropdown's result groups in order; unset lists popular searches, products and the no-results note.
dropdownSearchDropdownThe dropdown's width, colour scheme, corners, shadow and phone presentation.
previewbooleanHolds the dropdown open with sample results, as the editor shows a selected search block.