vue-single-select
simple autocomplete select dropdown component for Vue apps for you!
What It Does
vue-single-select provides a simple interface to replace regular select elements with an auto-complete select element like Chosen for jQuery.
What It Does Not Do
Nope no Multi Select. See vue-multiple-select for this.
No ajax loading.
No massive styling options (for now).
Usage
Install it
$ npm i vue-single-select
Register it
In your component:
Globally:
Use It
Use It Again
Use It Again
Dont like the Styling
You can override some of it. Like so:
Then all you need to do is provide some class definitions like so:
Note: Bootstrap 3 Users May want to increase the size of the icons.
If so do this:
Kitchen Sink
Meh, see props below.
Why vue-single-select is better
-
It handles custom label/value props for displaying options.
Other select components require you to conform to their format. Which often means data wrangling.
-
It's easier on the DOM.
Other components will load up all the options available in the select element. This can be heavy. vue-single-select makes an executive decision that you probably will not want to scroll more than N options before you want to narrow things down a bit. You can change this, but the default is 30.
-
Snappy Event Handling
- up and down arrows for selecting options
- enter to select first match
- remembers selection on change
- hit the escape key to, well, escape
-
Lightweight
- Why are the other packages so big and actually have dependencies?
-
It works for regular 'POST backs' to the server.
If you are doing a regular post or just gathering the form data you don't need to do anything extra to provide a name and value for the selected option.
-
Mine just looks nicer
-
It's simple!!
Available Props:
There are more props than I'd like. But I needed them so you might too.
Q&A
Q. What about Ajax?
A. Good question. Why aren't you passing that in as a prop?
Seriously, this is just a widget why does it need knowledge of it's data source?
Q. What about Templating?
A. Good question. Really. Working on it.
Q. What about Multiple Selects?
A. Nope not found here.
Q. Why doesn't it work?
A. You know I really didn't make this to be used without a bundler and the vue-loader. If you don't know what this means then checkout Parcel or Vue Cli to get started. You're going to want it anyway.
Or if you are ready to roll but need a helping hand use Laravel Mix
It's your one stop to success!