ion-searchbar
Searchbars represent a text field that can be used to search through a collection. They can be displayed inside of a toolbar or the main content.
A Searchbar should be used instead of an input to search lists. A clear button is displayed upon entering input in the searchbar's text field. Clicking on the clear button will erase the text field and the input will remain focused. A cancel button can be enabled which will clear the input and lose the focus upon click.
#
Keyboard Display#
AndroidBy default, tapping the input will cause the keyboard to appear with a magnifying glass icon on the submit button. You can optionally set the inputmode
property to "search"
, which will change the icon from a magnifying glass to a carriage return.
#
iOSBy default, tapping the input will cause the keyboard to appear with the text "return" on a gray submit button. You can optionally set the inputmode
property to "search"
, which will change the text from "return" to "go", and change the button color from gray to blue. Alternatively, you can wrap the ion-searchbar
in a form
element with an action
property. This will cause the keyboard to appear with a blue submit button that says "search".
#
Usage- ANGULAR
- JAVASCRIPT
- REACT
- STENCIL
- VUE
#
Properties#
animatedDescription | If true , enable searchbar animation. |
Attribute | animated |
Type | boolean |
Default | false |
#
autocompleteDescription | Set the input's autocomplete property. |
Attribute | autocomplete |
Type | "on" \| "off" \| "name" \| "honorific-prefix" \| "given-name" \| "additional-name" \| "family-name" \| "honorific-suffix" \| "nickname" \| "email" \| "username" \| "new-password" \| "current-password" \| "one-time-code" \| "organization-title" \| "organization" \| "street-address" \| "address-line1" \| "address-line2" \| "address-line3" \| "address-level4" \| "address-level3" \| "address-level2" \| "address-level1" \| "country" \| "country-name" \| "postal-code" \| "cc-name" \| "cc-given-name" \| "cc-additional-name" \| "cc-family-name" \| "cc-number" \| "cc-exp" \| "cc-exp-month" \| "cc-exp-year" \| "cc-csc" \| "cc-type" \| "transaction-currency" \| "transaction-amount" \| "language" \| "bday" \| "bday-day" \| "bday-month" \| "bday-year" \| "sex" \| "tel" \| "tel-country-code" \| "tel-national" \| "tel-area-code" \| "tel-local" \| "tel-extension" \| "impp" \| "url" \| "photo" |
Default | 'off' |
#
autocorrectDescription | Set the input's autocorrect property. |
Attribute | autocorrect |
Type | "off" \| "on" |
Default | 'off' |
#
cancelButtonIconDescription | Set the cancel button icon. Only applies to md mode.Defaults to "arrow-back-sharp" . |
Attribute | cancel-button-icon |
Type | string |
Default | config.get('backButtonIcon', 'arrow-back-sharp') as string |
#
cancelButtonTextDescription | Set the the cancel button text. Only applies to ios mode. |
Attribute | cancel-button-text |
Type | string |
Default | 'Cancel' |
#
clearIconDescription | Set the clear icon. Defaults to "close-circle" for ios and "close-sharp" for md . |
Attribute | clear-icon |
Type | string \| undefined |
Default | undefined |
#
colorDescription | The color to use from your application's color palette. Default options are: "primary" , "secondary" , "tertiary" , "success" , "warning" , "danger" , "light" , "medium" , and "dark" .For more information on colors, see theming. |
Attribute | color |
Type | string \| undefined |
Default | undefined |
#
debounceDescription | Set the amount of time, in milliseconds, to wait to trigger the ionChange event after each keystroke. This also impacts form bindings such as ngModel or v-model . |
Attribute | debounce |
Type | number |
Default | 250 |
#
disabledDescription | If true , the user cannot interact with the input. |
Attribute | disabled |
Type | boolean |
Default | false |
#
enterkeyhintDescription | A hint to the browser for which enter key to display. Possible values: "enter" , "done" , "go" , "next" ,"previous" , "search" , and "send" . |
Attribute | enterkeyhint |
Type | "done" \| "enter" \| "go" \| "next" \| "previous" \| "search" \| "send" \| undefined |
Default | undefined |
#
inputmodeDescription | A hint to the browser for which keyboard to display. Possible values: "none" , "text" , "tel" , "url" ,"email" , "numeric" , "decimal" , and "search" . |
Attribute | inputmode |
Type | "decimal" \| "email" \| "none" \| "numeric" \| "search" \| "tel" \| "text" \| "url" \| undefined |
Default | undefined |
#
modeDescription | The mode determines which platform styles to use. |
Attribute | mode |
Type | "ios" \| "md" |
Default | undefined |
#
placeholderDescription | Set the input's placeholder.placeholder can accept either plaintext or HTML as a string.To display characters normally reserved for HTML, they must be escaped. For example <Ionic> would become<Ionic> For more information: Security Documentation |
Attribute | placeholder |
Type | string |
Default | 'Search' |
#
searchIconDescription | The icon to use as the search icon. Defaults to "search-outline" inios mode and "search-sharp" in md mode. |
Attribute | search-icon |
Type | string \| undefined |
Default | undefined |
#
showCancelButtonDescription | Sets the behavior for the cancel button. Defaults to "never" .Setting to "focus" shows the cancel button on focus.Setting to "never" hides the cancel button.Setting to "always" shows the cancel button regardlessof focus state. |
Attribute | show-cancel-button |
Type | "always" \| "focus" \| "never" |
Default | 'never' |
#
showClearButtonDescription | Sets the behavior for the clear button. Defaults to "focus" .Setting to "focus" shows the clear button on focus if theinput is not empty. Setting to "never" hides the clear button.Setting to "always" shows the clear button regardlessof focus state, but only if the input is not empty. |
Attribute | show-clear-button |
Type | "always" \| "focus" \| "never" |
Default | 'always' |
#
spellcheckDescription | If true , enable spellcheck on the input. |
Attribute | spellcheck |
Type | boolean |
Default | false |
#
typeDescription | Set the type of the input. |
Attribute | type |
Type | "email" \| "number" \| "password" \| "search" \| "tel" \| "text" \| "url" |
Default | 'search' |
#
valueDescription | the value of the searchbar. |
Attribute | value |
Type | null \| string \| undefined |
Default | '' |
#
EventsName | Description |
---|---|
ionBlur | Emitted when the input loses focus. |
ionCancel | Emitted when the cancel button is clicked. |
ionChange | Emitted when the value has changed. |
ionClear | Emitted when the clear input button is clicked. |
ionFocus | Emitted when the input has focus. |
ionInput | Emitted when a keyboard input occurred. |
#
Methods#
getInputElementDescription | Returns the native <input> element used under the hood. |
Signature | getInputElement() => Promise<HTMLInputElement> |
#
setFocusDescription | Sets focus on the specified ion-searchbar . Use this method instead of the globalinput.focus() . |
Signature | setFocus() => Promise<void> |
#
CSS Custom PropertiesName | Description |
---|---|
--background | Background of the searchbar input |
--border-radius | Border radius of the searchbar input |
--box-shadow | Box shadow of the searchbar input |
--cancel-button-color | Color of the searchbar cancel button |
--clear-button-color | Color of the searchbar clear button |
--color | Color of the searchbar text |
--icon-color | Color of the searchbar icon |
--placeholder-color | Color of the searchbar placeholder |
--placeholder-font-style | Font style of the searchbar placeholder |
--placeholder-font-weight | Font weight of the searchbar placeholder |
--placeholder-opacity | Opacity of the searchbar placeholder |