1.0.0 • Published 4 years ago

vue-weblineindia-multiselect v1.0.0

Weekly downloads
6
License
MLT
Repository
github
Last release
4 years ago

VueJS Multiselect Dropdown Component

vue-weblineindia-multiselect is a feature rich select / dropdown / typeahead component. It provides a default template that fits most use cases for a filterable multi-select dropdown. A lightweight component with easy accessibility and customization.

  • Tagging
  • Filtering / Searching
  • Accessible
  • Vuex Support
  • AJAX Support
  • SSR Support
  • Zero dependencies
  • Select Single/Multiple Options
  • Customizable with slots and SCSS variables

Table of contents

Browser Support

ChromeFirefoxSafariEdgeIE
83.0 ✔77.0 ✔13.1.1 ✔83.0 ✔11.9 ✔

Demo

npm.io

Getting started

yarn add vue-weblineindia-multiselect

# or use npm

npm install vue-weblineindia-multiselect

Then, import and register the component:

import Vue from "vue";
import multiSelect from "vue-weblineindia-multiselect";

Vue.component("v-multiselect", multiSelect);

The component itself does not include any CSS. You'll need to include it separately:

import "vue-weblineindia-multiselect/lib/vue-select.css";

Alternatively, you can import the scss for complete control of the component styles:

@import "vue-weblineindia-multiselect/src/scss/vue-select.scss";

Usage

<template>
  <div id="app">
    <v-multiselect v-model="value" :options="optionArray" multiple :placeholder="'Select'"/>
  </div>
</template>
export default {
  data() {
    return {
      value: [],
      optionArray: ["option 1", "option 2", "option 3", "option 4"]
    };
  },
}

Available Props

PropData TypeDefaultDescription
append-iconstring'$dropdown'Appends an icon to the component, uses the same syntax as v-icon
append-outer-iconstringundefinedAppends an icon to the outside the component's input, uses same syntax as v-icon
attachanyfalseSpecifies which DOM element that this component should detach to.String can be any valid querySelector and Object can be any valid Node. This will attach to the root v-app component by default.
autofocusbooleanfalseEnables autofocus
background-colorstringundefinedChanges the background-color of the input
cache-itemsbooleanfalseKeeps a local unique copy of all items that have been passed through the items prop.
chipsbooleanfalseChanges display of selections to chips.
clear-iconstring'$clear'Applied when using clearable and the input is dirty.
clearablebooleanfalseAdd input clear functionality, default icon is Material Icons clear.
colorstringundefinedApplies specified color to the control - it can be the name of material color (for example success or purple) or css color (#033 or rgba(255, 0, 0, 0.5)).
counterboolean/number/stringundefinedCreates counter for input length; if no number is specified, it defaults to 25. Does not apply any validation.
counter-valuefunctionnull
darkbooleanfalseApplies the dark theme variant to the component
deletable-chipsbooleanfalseAdds a remove icon to selected chips
densebooleanfalseReduces the input height
disable-lookupbooleanfalseDisables keyboard lookup
disabledbooleanfalseDisables the input
eagerbooleanfalseWill force the components content to render on mounted. This is useful if you have content that will not be rendered in the DOM that you want crawled for SEO.
errorbooleanfalsePuts the input in a manual error state
error-countnumber/string1The total number of errors that should display at once
error-messagesstring/array[]Puts the input in an error state and passes through custom error messages. Will be combined with any validations that occur from the rules prop. This field will not trigger validation
filledbooleanfalseApplies the alternate filled input style
filter(item: object, queryText: string, itemText: string): booleanThe function used for filtering items
flatbooleanfalseRemoves elevation (shadow) added to element when using the solo or solo-inverted props
full-widthbooleanfalseDesignates input type as full-width
heightnumber/stringundefinedSets the height of the input
hide-detailsboolean/stringundefinedHides hint and validation errors. When set to auto messages will be rendered only if there's a message (hint, error message, counter value etc) to display
hide-selectedbooleanfalseDo not display in the select menu items that are already selected
hintstringundefinedHint text
idstringundefinedSets the DOM id on the component
item-colorstring'primary'Sets color of selected items
item-disabledarray/string/functiondisabledSet property of items's disabled value
item-textarray/string/functiontextSet property of items's text value
item-valuearray/string/functionvalueSet property of items's value
itemsarray[]Can be an array of objects or array of strings. When using objects, will look for a text and value field. This can be changed using the item-text and item-value props. Objects that have a header or divider property are considered special cases and generate a list header or divider; these items are not selectable.
labelstringSets input label
lightbooleanfalseApplies the light theme variant to the component.
loader-heightnumber/string2Specifies the height of the loader
loadingboolean/stringfalseDisplays linear progress bar. Can either be a String which specifies which color is applied to the progress bar (any material color or theme color - primary, secondary, success, info, warning, error) or a Boolean which uses the component color (set by color prop - if it's supported by the component) or the primary color
menu-propsarray/string/object{ "closeOnClick": false, "closeOnContentClick": false, "disableKeys": true, "openOnClick": false, "maxHeight": 304 }Pass props through to the v-menu component. Accepts either a string for boolean props menu-props="auto, overflowY", or an object :menu-props="{ auto: true, overflowY: true }".
messagesstring/array[]Displays a list of messages or message if using a string.
multiplebooleantrueChanges select to multiple. Accepts array for value.
no-data-textstring'$vuetify.noDataText'Display text when there is no data.
open-on-clearbooleanfalseWhen using the clearable prop, once cleared, the select menu will either open or stay open, depending on the current state.
outlinedbooleanfalseApplies the outlined style to the input.
persistent-hintbooleanfalseForces hint to always be visible.
placeholderstringSelectSets the input’s placeholder text.
prefixstringundefinedDisplays prefix text.
prepend-iconstringundefinedPrepends an icon to the component, uses the same syntax as v-icon.
prepend-inner-iconstringundefinedPrepends an icon inside the component's input, uses the same syntax as v-icon.
readonlybooleanfalsePuts input in readonly state.
return-objectbooleanfalseChanges the selection behavior to return the object directly rather than the value specified with item-value.
reversebooleanfalseReverses the input orientation.
roundedbooleanfalseAdds a border radius to the input.
rulesarray[]Accepts an array of functions that take an input value as an argument and return either true / false or a string with an error message.
shapedbooleanfalseRound if outlined and increase border-radius if filled. Must be used with either outlined or filled.
single-linebooleanfalseLabel does not move on focus/dirty.
small-chipsbooleanfalseChanges display of selections to chips with the small property.
solobooleanfalseChanges the style of the input.
solo-invertedbooleanfalseReduces element opacity until focused.
successbooleanfalsePuts the input in a manual success state.
success-messagesstring/array[]Puts the input in a success state and passes through custom success messages..
suffixstringundefinedDisplays suffix text.
typestringtextSets input type.
validate-on-blurbooleanfalseDelays validation until blur event.
valueanydefaultThe input's value.
value-comparatorfunction(a: any, b: any): booleanThe comparison algorithm used for values.

Events

NameDescriptionValue
blurEmitted when the input is blurredEvent
changeEmitted when the input is changed by user interactionany
clickEmitted when input is clickedMouseEvent
click:appendEmitted when appended icon is clickedEvent
click:append-outerEmitted when appended outer icon is clickedEvent
click:clearEmitted when clearable icon clickedEvent
click:prependEmitted when prepended icon is clickedEvent
click:prepend-innerEmitted when prepended inner icon is clickedEvent
focusEmitted when component is focusedEvent
inputThe updated bound modelany
keydownEmitted when any key is pressedKeyboardEvent
mousedownEmitted when click is pressedMouseEvent
mouseupEmitted when click is releasedMouseEvent
update:errorThe error.sync eventboolean
update:list-indexEmitted when menu item is selected using keyboard arrowsnumber
update:search-inputThe search-input.sync eventstring

Slots

NameDescription
appendAdds an item inside the input and after input content
append-itemAdds an item after menu content
append-outerAdds an item outside the input and after input content
defaultThe default Vue slot.
itemDefine a custom item appearance
labelReplaces the default label
messageCustomize the messages slot.
no-dataDisplayed when there are no filtered items.
prependAdds an item outside the input and before input content.
prepend-innerAdds an item inside the input and before input content.
prepend-itemAdds an item before menu content.
progressSlot for custom progress linear (displayed when loading prop is not equal to Boolean False).
selectionDefine a custom selection appearance.

Sass

NameDefault
$select-active-chip-opacity0.2 !default;
$select-active-icon-fliptrue !default;
$select-chip-margin4px !default;
$select-chips-box-enclosed-selections-min-height68px !default;
$select-chips-dense-selections-min-height40px !default;
$select-chips-dense-selections-padding-top40px !default;
$select-chips-selections-padding-top42px !default;
$select-dense-chip-margin0 4px 0 4px !default;
$select-dense-selections-margin5px 4px 3px 0 !default;
$select-outlined-dense-selections-padding-top4px 0 !default;
$select-outlined-selections-padding-top8px 0 !default;
$select-prefix-line-height20px !default;
$select-selected-chip-opacity.22 !default;
$select-selections-line-height18px !default;
$select-selections-margin7px 4px 7px 0 !default;
$select-selections-padding-top20px !default;
$select-small-chips-dense-selections-min-height38px !default;
$select-small-chips-selections-min-height26px !default;

Want to Contribute?

  • Created something awesome, made this code better, added some functionality, or whatever (this is the hardest part).
  • Fork it.
  • Create new branch to contribute your changes.
  • Commit all your changes to your branch.
  • Submit a pull request.

Need Help?

We also provide a free, basic support for all users who want to use this VueJS based Multiselect Dropdown component in their software project. In case you want to customize this Multiselect dropdown component to suit your development needs, then feel free to contact our VueJS developers.


Collection of Components

We have built many other components and free resources for software development in various programming languages. Kindly click here to view our Free Resources for Software Development.


Changelog

Detailed changes for each release are documented in CHANGELOG.md.

Credits

vue-weblineindia-multiselect is inspired by vue-select.

License

MIT

Keywords

vue-weblineindia-multiselect,multiselect,select,vue components,vuejs,vuejs component