1.0.12 • Published 5 years ago

vue-dynamic-dropdown v1.0.12

Weekly downloads
274
License
MIT
Repository
github
Last release
5 years ago

vue-dynamic-dropdown

A Highly Customizable, easy-to-use, elegant, dropdown component

Feedback would be much appreciated, questions, suggestions, issues are more than welcome.

MIT License view on npm

Demo

A dropdown demo gif

Edit Vue Dynamic Dropdown Component

Usage:

First

Install via NPM npm i vue-dynamic-dropdown

Second

Require in your project:

var VueDropdown = require('vue-dynamic-dropdown');

or ES6 syntax:

import VueDropdown from 'vue-dynamic-dropdown'

Third

You can register the component globally:

Vue.component('vue-dropdown', VueDropdown);

Or locally in a single Vue component:

components: {
  VueDropdown
}

Insert the following selector anywhere in your project (global) or in your existing component (local): NOTE: To get up and running quickly the package now supports rendering just the selector with default values.

<vue-dropdown></vue-dropdown>

Docs:

config: {...} is a configuration object that is to be bound to vue-dropdown, API properties are:

Basics

PropertyTypeDescription
optionsarrayHolds the inner selection options of the dropdown (shown when open), each single option is an object that has the value key that pairs with the given value e.g { value: '1st Option' }
widthnumberDetermines the width of the dropdown button & options drawer
placeholderstringThe text shown on the dropdown button by default
prefixstringA text prefix that will be added before the placeholder text

Customized Styling

PropertyTypeDescription
backgroundColorstringSet the dropdown button & options area background color
hoverBackgroundColorstringSet the dropdown button & options hover background color
borderstringSet the dropdown button & options border
textColorstringSet the dropdown button & options text color

Events

Event NameReturnsDescription
setSelectedOptionOption ObjectClicking a dropdown option emits an option data object upwards

Listening to the event e.g:

<vue-dropdown @setSelectedOption="myLocalSetterFunction($event)"></vue-dropdown>

Implementation Example

Define your config options object in the component importing VueDropdown e.g

data: function() {
    return {
        config: {
            options: [
                {
                    value: "option 1"
                },
                {
                    value: "option 2"
                },
                {
                    value: "option 3"
                },
            ],
            prefix: "The",
            backgroundColor: "green"
        }
    }
}

And bind it to the selector like so

<vue-dropdown :config="config"></vue-dropdown>

If you like to support my open-source contributions and feeling generous, feel free to:

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.51

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago