InputSelect
A plain an simple input select.
Implements mixins RequiredInputMixin and BasicInputMixin.
We will use the following options:
js
const selectOptions = [
{ value: { id: 1, text: "WORKER" }, text: "I'm a worker" },
{ value: { id: 2, text: "FREELANCE" }, text: "I'm a freelance" },
{ value: { id: 3, text: "COMPANY" }, text: "I'm a company" },
{ value: { id: 4, text: "OTHER" }, text: "None of the above" }
]html
<Card>
<Form>
<InputSelect name="select" label="Select an option" placeholder="Select a job..." required :options="selectOptions" />
</Form>
</Card>Props
options. Changes selectable options.
optionValueKey(defaultvalue) andoptionDefaultKey(defaulttext). Changes which values fromoptionswill pick-up.
allowClear(defaultfalse): allows for clearing selected value with a top button.
html
<Card>
<Form>
<InputSelect
name="select"
label="Select an option"
placeholder="Select a job..."
required
allowClear
:options="selectOptions" />
</Form>
</Card>allowEmpty(defaultfalse): allow empty selection. Similar torequired, butallowEmptyhas priority.
html
<Card>
<Form>
<InputSelect
name="select"
label="Select an option"
placeholder="Select a job..."
allowEmpty
:options="selectOptions" />
</Form>
</Card>readOnly(defaultfalse): ifvalueis read-only and input select is not selectable.
html
<Card>
<Form>
<InputSelect
name="select"
label="Select an option"
placeholder="Select a job..."
readOnly
:options="selectOptions"
:initialValue="selectOptions[0].value" />
</Form>
</Card>resetValueOnOptionsChange(defaultfalse): wether to reset selected value if selectable options prop changes.
allowSearch(defaultfalse): if allow search in selectable options.
html
<Card>
<Form>
<InputSelect
name="select"
label="Select an option"
placeholder="Select a job..."
allowSearch
:options="selectOptions" />
</Form>
</Card>allowAddOptions(defaultfalse): if allow to add a new selectable option from search input.
html
<Card>
<Form>
<InputSelect
name="select"
label="Select an option"
placeholder="Select a job..."
allowSearch
allowAddOptions
:options="selectOptions" />
</Form>
</Card>clearWhenDisable(defaultfalse): wether to reset selected value if disabled prop changes to enabled.
clearWhenOptionsChange(defaultfalse): wether to reset selected value if selectable options prop changes.
placeholder(defaultnull): text shown when no selected value.
html
<Card>
<Form>
<InputSelect name="select" label="Select an option" placeholder="Select your current job status..." required :options="selectOptions" />
</Form>
</Card>mountOptionsOutside(defaultfalse): wether to mount selectable values drop-down outside or inside the component. Inside should be faster, but outside can prevent some glitches when input is on a modal or inside a box withoverflow: hidden;.
html
<Card>
<Form>
<InputSelect
name="select"
label="Select an option"
placeholder="Select a job..."
mountOptionsOutside
:options="selectOptions" />
</Form>
</Card>Emits
changeField. Custom change event.
Vuersatile Components