Documentation
Feedback
Guides
VTEX IO Apps

VTEX IO Apps
Search Bar
vtex.store-components
Version: 3.151.2
Latest version: 3.178.2

This page is about version 3.151.2 of the app, which is not the most recent version. The latest stable version is 3.178.2.

Description

Search Bar is a VTEX Component that shows a search bar with autocomplete options and displays the matching products as well. This component can be imported and used by any VTEX App.

:loudspeaker: Disclaimer: Don't fork this project; use, contribute, or open issue with your feature request.

Table of Contents

Usage

You should follow the usage instruction in the main README.

Then, add search-bar block into your app theme, as we do in our Store Header.

Props

Prop nameTypeDescriptionDefault value
attemptPageTypeSearchBooleanIf true when clicked on result link of brand, department or category will link to the corresponding brand, department or category page. When false will always go to a full text search page.false
autocompleteAlignmentHorizontalAlignmentAutocomplete Horizontal alignment.left
autocompleteFullWidthBooleanIf true, the autocomplete will fill the whole window horizontally.false
autoFocusBooleanDefine if the search input should autofocus or not-
blurOnSubmitBooleanDefine if input should blur on submit.false
compactModeBooleanDefine when to use the compact version of the component-
customSearchPageUrlstringTemplate for a custom url. It can have a substring ${term} used as placeholder to interpolate the searched term. (e.g. /search?query=${term})-
displayModeDisplayModeDefine the component display mode, such as which buttons should be visible.clear-button
emptyPlaceholderString!Shows a placeholder when the ResultList hasn't results to displayed-
hasIconLeftBooleanDefine if the search icon is on left or right position-
maxWidthNumber | StringMax width of the search bar-
minSearchTermLengthNumberIf defined, it will block searches where the term length is lesser than minSearchTermLength.-
openAutocompleteOnFocusBooleanDefine if autocomplete should be open on input focus or not.false
placeholderString!Placeholder to be used on the input-
inputTypeenumDefines the value for the type HTML attribute (from the <input> field). Possible values are: search and text. We strongly recommend you to use search as it fixes some iOS issues. The text value is only kept as default for backwards compatibility.text
containerModeenumDefines how the autocomplete component should be displayed. Possible values are: overlay (suggestions overlapping other components) and container (displays the suggestion within a container).overlay
iconClassesString
{"base64":"  ","img":{"width":71,"height":20,"type":"svg","mime":"image/svg+xml","wUnits":"px","hUnits":"px","url":"https://img.shields.io/badge/-deprecated-red"}}
Custom classes for the search icon Use the CSS handle searchBarIcon.
-
submitOnIconClickBoolean
{"base64":"  ","img":{"width":71,"height":20,"type":"svg","mime":"image/svg+xml","wUnits":"px","hUnits":"px","url":"https://img.shields.io/badge/-deprecated-red"}}
- Define if search icon should submit on click. Use the displayMode prop instead.
false
classesCustomCSSClassesUsed to override default CSS handles. To better understand how this prop works, we recommend reading about it here. Note that this is only useful if you're using this block as a React component.undefined
disableBlurAndTouchEndHandlerBooleanThe autocomplete can have touchable/clickable components. Interacting with those components may trigger blur and touch events that will close the autocomplete. When set to true, this prop will disable those handlers.false

DisplayMode

Enum nameEnum valueEmpty stateFilled state
clear-button'clear-button'
{"base64":"  ","img":{"width":240,"height":38,"type":"png","mime":"image/png","wUnits":"px","hUnits":"px","length":2136,"url":"https://user-images.githubusercontent.com/12702016/74764904-5cc5e580-5261-11ea-9df8-484cf457c266.png"}}
{"base64":"  ","img":{"width":246,"height":38,"type":"png","mime":"image/png","wUnits":"px","hUnits":"px","length":2405,"url":"https://user-images.githubusercontent.com/12702016/74764917-60f20300-5261-11ea-8911-11c8fd9582d9.png"}}
search-and-clear-buttons'search-and-clear-buttons'
{"base64":"  ","img":{"width":265,"height":38,"type":"png","mime":"image/png","wUnits":"px","hUnits":"px","length":2294,"url":"https://user-images.githubusercontent.com/12702016/74764924-62bbc680-5261-11ea-9f1d-2118274da996.png"}}
{"base64":"  ","img":{"width":265,"height":38,"type":"png","mime":"image/png","wUnits":"px","hUnits":"px","length":2865,"url":"https://user-images.githubusercontent.com/12702016/74764928-64858a00-5261-11ea-9ed2-42da887e6641.png"}}
search-button'search-button'
{"base64":"  ","img":{"width":240,"height":38,"type":"png","mime":"image/png","wUnits":"px","hUnits":"px","length":2136,"url":"https://user-images.githubusercontent.com/12702016/74764929-65b6b700-5261-11ea-815c-ecc9f0c44e0f.png"}}
{"base64":"  ","img":{"width":240,"height":38,"type":"png","mime":"image/png","wUnits":"px","hUnits":"px","length":2528,"url":"https://user-images.githubusercontent.com/12702016/74764934-66e7e400-5261-11ea-8a86-59da9a1c0faa.png"}}

HorizontalAlignment

Enum nameEnum value
center'center'
left'left'
right'right'

CSS Handles

Below, we describe the namespace that are defined in the SearchBar.

Class name
compactMode
externalSearchButtonWrapper
paddingInput
searchBarContainer
searchBarInnerContainer--opened
searchBarInnerContainer--filled
searchBarIcon--clear
searchBarIcon--external-search
searchBarIcon--prefix
searchBarIcon--search
searchBarIcon
suffixWrapper
See also
Vtex.store Components
VTEX IO Apps
VTEX App Store
VTEX IO Apps