Input Options
Input options allows the user to type text and select an option at the same time
Basic Usage
const options = [
{
"id": "mg",
"name": "mg"
},
{
"id": "percent",
"name": "%"
}
];
<InputOptions :options="options" />
The model value of this component yields both the <Select />
and the <Input />
selected values, as option
and value
respectively.
Besides that, it includes isValueChange
to indicate whether the text value has changed or not, as well as the type
to indicate if the change was from the select
or input
.
modelValue:
Playground
Field
You can specify properties that will be passed down to the rendered <Field />
:
Label
<InputOptions label="THC value" />
Error and Hint texts
<InputOptions error-text="I'm an error" />
<InputOptions hint-text="I'm a hint" />
Input
You can specify properties that will be passed down to the rendered <Input />
:
Type
<InputOptions type="password" />
Placeholder
<InputOptions placeholder="Type something..." />
Select
You can specify properties that will be passed down to the rendered <Select />
:
Options
The options
property accepts an array of options that can be customized with trackBy
and displayBy
properties.
const customOptions = [
{
"displayProp": "cm",
"valueProp": "centimeter"
},
{
"displayProp": "in",
"valueProp": "inch"
}
];
<InputOptions :options="customOptions" trackBy="valueProp" displayBy="displayProp" />
No truncate
<template>
<InputOptions :class="$style.trunc" :noTruncate="true" :options="truncateOptions" />
</template>
<style module>
.trunc {
:global(.stash-select) {
width: 150px;
}
}
</style>
Disabled
WARNING
If the user cannot take any action to make the field editable, the is-read-only
prop should be used instead.
See Disabled vs read-only for details.
<InputOptions disabled />
Read Only
Similar to disabled fields, read-only fields cannot be edited. However, unlike disabled fields, read-only fields are able to receive focus, but are not intended to become editable.
<InputOptions
is-read-only
label="Quantity"
:options="options"
:model-value="{ value: 10, option: options[0] }"
/>
API
See the documentation below for a complete reference to all the props and classes available to the components mentioned here.