Skip to main content
Version: Bleeding Edge 🚧

SearchBar

Import

import { SearchBar } from '@rn-vui/themed';

Theme Key

SearchBar

Usage

iOS

Android

Interaction methods

methoddescription
focuscall focus on the textinput (example)
blurcall blur on the textinput (example)
clearcall clear on the textinput (example)
cancel(Android and iOS SearchBars only) call cancel on the SearchBar (left arrow on Android, Cancel button on iOS). This will basically blur the input and hide the keyboard (example)

Store a reference to the SearchBar in your component by using the ref prop provided by React (see docs):

<SearchBar
ref={search => this.search = search}
...
/>

You can then access SearchBar methods like so:

this.search.focus();
this.search.blur();
this.search.clear();
this.search.cancel(); // Only available if `platform` props is "ios" | "android"

Props

note

Includes all Input props.

NameTypeDefaultDescription
cancelButtonPropsText StyleCancel Button Props Only with 'platform' prop set to 'ios'
cancelButtonTitlestringCancel Button Title Only with 'platform' prop set to 'ios'
cancelIconIconNodeClear Icon Only with 'platform' prop set to 'android'
clearIconIconNodeClear IconClear Icon Only with 'platform' prop set to 'ios'
containerStyleView StyleStyle for container
inputContainerStyleView StyleStyle for input container
inputStyleText StyleInput Style
leftIconContainerStyleView StyleLeft Icon Container Style
lightThemeboolean
loadingPropsActivityIndicatorPropsActivityIndicatorProps
onCancel(() => any) | (() => any)Callback Function on cancel icon press Only with 'platform' prop set to 'android' or 'ios
onClearFunction
onKeyboardHideFunctionCallback Function on keyboard hides Only with 'platform' prop set to 'android'
platformdefault | android | iosdefaultWarning: Some props are platform specific and will not work on other platform
rightIconContainerStyleView StyleRight Icon Container Style
roundboolean
searchIconIconNodeIcon for searchIcon for search Only with 'platform' prop set to 'ios'
showCancelbooleanShow cancel Only with 'platform' prop set to 'ios'
showLoadingbooleanShow loading

Playground

Loading...