Searchbox
Demos
Stylistic variants
Available stylistic values for the ui
prop: primary
.
<template>
<article>
<veui-searchbox/>
<veui-searchbox ui="primary"/>
</article>
</template>
<script>
import { Searchbox } from 'veui'
export default {
components: {
'veui-searchbox': Searchbox
}
}
</script>
Size variants
Available size values for the ui
prop: large
/small
.
<template>
<article>
<veui-searchbox ui="large"/>
<veui-searchbox/>
<veui-searchbox ui="small"/>
</article>
</template>
<script>
import { Searchbox } from 'veui'
export default {
components: {
'veui-searchbox': Searchbox
}
}
</script>
Read-only and disabled
<template>
<article>
<section>
<veui-radio-group
v-model="state"
:items="states"
/>
</section>
<section>
<veui-searchbox
:readonly="isReadonly"
:disabled="isDisabled"
/>
<veui-searchbox
:readonly="isReadonly"
:disabled="isDisabled"
ui="primary"
/>
</section>
</article>
</template>
<script>
import { Searchbox, RadioGroup } from 'veui'
export default {
components: {
'veui-searchbox': Searchbox,
'veui-radio-group': RadioGroup
},
data () {
return {
state: null,
states: [
{
label: 'Normal',
value: null
},
{
label: 'Read-only',
value: 'readonly'
},
{
label: 'Disabled',
value: 'disabled'
}
]
}
},
computed: {
isReadonly () {
return this.state === 'readonly'
},
isDisabled () {
return this.state === 'disabled'
}
}
}
</script>
Suggestion list
<template>
<article>
<veui-searchbox
v-model="value"
clearable
:suggestions="suggestions"
replace-on-select
@select="handleSelect"
/>
</article>
</template>
<script>
import { Searchbox } from 'veui'
import toast from 'veui/managers/toast'
export default {
components: {
'veui-searchbox': Searchbox
},
data () {
return {
value: '',
browsers: [
'Google Chrome',
'Apple Safari',
'Microsoft Edge',
'Mozilla Firefox',
'Opera',
'Vivaldi',
'Internet Explorer',
'Maxthon',
'Android Browser',
'UC Browser',
'Samsung Internet',
'QQ Browser'
]
}
},
computed: {
suggestions () {
if (!this.value) {
return []
}
return this.browsers.filter(browser => {
return browser.toLowerCase().indexOf(this.value.toLowerCase()) !== -1
})
}
},
methods: {
handleSelect ({ value }) {
toast.info(value)
}
}
}
</script>
API
Props
Name | Type | Default | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
ui | string | - | Style variants.
| |||||||||
placeholder | string | - | The placeholder text of the search box. | |||||||||
value | string | - |
The value of the search box. | |||||||||
autofocus | boolean | false | Whether the search box gains focus automatically. | |||||||||
clearable | boolean | false | Whether the clear button is displayed. | |||||||||
select-on-focus | boolean | false | Whether to select all content upon focus. | |||||||||
composition | boolean | false | Whether the search box triggers value change upon composition of IME. | |||||||||
suggestions | Array<string>|Array<Object> | - | The suggestion list. When the item type is
| |||||||||
replace-on-select | boolean | true | Whether to replace the content with suggestion item value when it's selected. | |||||||||
suggest-trigger | Array<string>|string | input | Specifies when the suggestion list is displayed. Can be either an event name or a list of event names.
| |||||||||
disabled | boolean | false | Whether the search box is disabled. | |||||||||
readonly | boolean | false | Whether the search box is read-only. |
Slots
Name | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
suggestions | The content of the entire suggestion list.
| |||||||||
suggestions-before | The content before the suggestion list. | |||||||||
suggestions-after | The content after the suggestion list. | |||||||||
suggestion | The content of each suggestion option.
Additionally, custom properties apart from the listed ones will also be passes into the scope object via When |
Events
Name | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
input | Triggers when the input value changes. The callback parameter list is
| |||||||||
suggest | Triggers when the suggestion list is displayed. The callback parameter list is
| |||||||||
select | Triggered when an suggestion option is selected. The callback parameter list is
| |||||||||
search | Triggered when the input value is submitted. The callback parameter list is
|
Icons
Name | Description |
---|---|
search | Search. |