InputSelect.vue component is a reusable Vue.js Composition API component for creating select dropdowns. It supports various configurations for options, including arrays, objects, and shaped data, making it versatile for different use cases.
Features
Dynamic Options
Accepts both arrays and objects as data sources for dropdown options.
Data Shaping
Supports key-value mapping for custom option structures.
Nullable Options
Allows the inclusion of an empty option in the dropdown.
Customizable Label
Displays a label for the select dropdown.
Multiple Select
Works with multiple selection.
Usage
Basic Example
Multiple Select
Disabled Select
Object Options with Shape
Props
The value bound to the selected option.
The input type (not commonly used with this component).
The data source for the dropdown options.
Defines the keys for mapping option values (
value) and labels (text).The width of the component as a percentage.
The label displayed above the select element.
Displays an error message and applies error styling when provided.
Text for the empty option (
false disables the empty option).Allows an empty value option if set to
true.Example Use Cases
Reactive Selection
Bind the selected value usingv-model:
Notes
- The
labelEmptyprop can provide a placeholder or empty selection option, e.g.,labelEmpty="Select one". - The
nullableprop must be set totrueif you want the empty option to be selectable. - Supports two-way data binding with
v-modelfor dynamic updates.