Search bar
Search bar
Component demo
Interactive example
<ic-search-barlabel="What is your favourite coffee?"placeholder="Start typing to search…"></ic-search-bar>
<IcSearchBarlabel="What is your favourite coffee?"options={options}onIcChange={(ev)=>console.log(ev.detail.value)}onIcSubmitSearch={(ev)=>console.log(ev.detail.value)}placeholder="Start typing to search…"/>
Search bar details
Props
All components also accept native properties supported by the DOM, such asclassName
and
style
.
|
|
|
---|---|---|
|
The label for the search bar. |
|
|
The hint text for the hidden assistive description element. |
|
|
The automatic capitalisation of the text value as it is entered/edited by the user. Available options: "off", "none", "on", "sentences", "words", "characters". |
|
|
The state of autocompletion the browser can apply on the text value. |
|
|
The state of autocorrection the browser can apply when the user is entering/editing the text value. |
|
|
If |
|
|
The number of characters until suggestions appear. The submit button will be disabled until the inputted value is equal to or greater than this number. |
|
|
The amount of time, in milliseconds, to wait to trigger the |
|
|
Specify whether to disable the built in filtering. For example, if options will already be filtered from external source.
If |
|
|
If |
|
|
The text displayed when there are no options in the option list. |
|
|
If |
|
|
Specify whether the search bar fills the full width of the container.
If |
|
|
The helper text that will be displayed for additional field guidance. |
|
|
If |
|
|
The custom name for the label field to correspond with the IcMenuOption type. |
|
|
Trigger loading state when fetching options asynchronously |
|
|
Change the message displayed when external loading times out. |
|
|
Change the message displayed whilst the options are being loaded externally. |
|
|
The name of the control, which is submitted with the form data. |
|
|
The suggested search options. |
|
|
The placeholder value to display. |
|
|
If |
|
|
If |
|
|
Specify the mode search bar uses to search. |
|
|
The size of the search bar component. |
|
|
If |
|
|
Sets the theme color to the dark or light theme color. "inherit" will set the color based on the system settings or ic-theme component. |
|
|
If using external filtering, set a timeout for when loading takes too long. |
|
|
The value of the search input. |
|
|
The custom name for the value field to correspond with the IcMenuOption type. |
|
The label for the search bar. |
The hint text for the hidden assistive description element. |
The automatic capitalisation of the text value as it is entered/edited by the user. Available options: "off", "none", "on", "sentences", "words", "characters". |
The state of autocompletion the browser can apply on the text value. |
The state of autocorrection the browser can apply when the user is entering/editing the text value. |
If |
The number of characters until suggestions appear. The submit button will be disabled until the inputted value is equal to or greater than this number. |
The amount of time, in milliseconds, to wait to trigger the |
Specify whether to disable the built in filtering. For example, if options will already be filtered from external source.
If |
If |
The text displayed when there are no options in the option list. |
If |
Specify whether the search bar fills the full width of the container.
If |
The helper text that will be displayed for additional field guidance. |
If |
The custom name for the label field to correspond with the IcMenuOption type. |
Trigger loading state when fetching options asynchronously |
Change the message displayed when external loading times out. |
Change the message displayed whilst the options are being loaded externally. |
The name of the control, which is submitted with the form data. |
The suggested search options. |
The placeholder value to display. |
If |
If |
Specify the mode search bar uses to search. |
The size of the search bar component. |
If |
Sets the theme color to the dark or light theme color. "inherit" will set the color based on the system settings or ic-theme component. |
If using external filtering, set a timeout for when loading takes too long. |
The value of the search input. |
The custom name for the value field to correspond with the IcMenuOption type. |
CSS Custom Properties
|
|
---|---|
|
|
|
Events
All components also accept native events supported by the DOM, such as
onClick
and
onKeyDown
.
|
|
|
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Methods
|
|
|
---|---|---|
|
|
|
|
Variants
With options (no filtering)
Interactive example
<ic-search-barplaceholder="Start typing to search…"label="What is your favourite coffee?"disable-auto-filtering="true"></ic-search-bar><br><ic-typography><p>All options will be displayed as you type</p></ic-typography>
<IcSearchBarplaceholder="Start typing to search…"label="What is your favourite coffee?"disableAutoFilteringoptions={options}/><br/><IcTypography><p>All options will be displayed as you type</p></IcTypography>
With helper text
Interactive example
<ic-search-barplaceholder="Start typing to search…"label="What is your favourite coffee?"helper-text="Coffee options will be displayed as you type."></ic-search-bar>
<IcSearchBarplaceholder="Start typing to search…"label="What is your favourite coffee?"helperText="Coffee options will be displayed as you type."options={options}/>
With hidden label
Interactive example
<ic-search-barplaceholder="Start typing to search…"label="What is your favourite coffee?"hide-label="true"></ic-search-bar>
<IcSearchBarplaceholder="Start typing to search…"label="What is your favourite coffee?"hideLabeloptions={options}/>
Disabled
Interactive example
<ic-search-barlabel="What is your favourite coffee?"disabled="true"></ic-search-bar>
<IcSearchBarlabel="What is your favourite coffee?"disabledoptions={options}/>
Size small
Interactive example
<ic-search-barlabel="What is your favourite coffee?"size="small"></ic-search-bar>
<IcSearchBarlabel="What is your favourite coffee?"size="small"options={options}/>
Custom filtering example
This example shows how to filter data asynchronously when the value in the input field changes. The data is mocked and displayed after a one second delay, but could be replaced with a call to an API or database.
Interactive example
<ic-search-barplaceholder="Start typing to search…"label="What is your favourite coffee?"debounce="300"disable-auto-filtering="true"></ic-search-bar>
<IcSearchBarplaceholder="Start typing to search…"label="What is your favourite coffee?"debounce={300}disableAutoFilteringoptions={results}onIcChange={changeHandler}/>
Theme
Interactive example
<ic-search-barlabel="What is your favourite coffee?"placeholder="Start typing to search…"theme="dark"></ic-search-bar>
<IcSearchBarlabel="What is your favourite coffee?"options={options}placeholder="Start typing to search…"theme="dark"/>