1.0.6 • Published 3 years ago

vs-select v1.0.6

Weekly downloads
237
License
MIT
Repository
github
Last release
3 years ago

Vue Simple Select

🗃 A simple vue select. Perfect for all your select scenarios.

A light weight vue plugin built groundup.

npm npm

forthebadge forthebadge forthebadge forthebadge forthebadge forthebadge

📺 Live Demo

Code Sandbox: Link

🛠 Install

npm i vs-select
yarn add vs-select

🚀 Usage

<template>
  <vs-select :options="options1"></vs-select>
  <vs-multiselect :options="options1"></vs-multiselect>
</template>

<script>
  import { VsSelect, VsMultiselect } from 'vs-select';

  export default {
    components: {
      VsSelect,
      VsMultiselect,
    },

    data() {
      return {
        options1: ['Derek', 'Ryan', 'BB', 'Chris'],
        options2: [
          { label: 'Derek', value: 'D' },
          { label: 'Ryan', value: 'R' },
          { label: 'BB', value: 'BB' },
          { label: 'Chris', value: 'C' },
        ],
      };
    },
  };
</script>

🌎 CDN

<script src="https://unpkg.com/vs-select@1.0.6/dist/vs-select.min.js"></script>
<template>
  <vs-select :options="options1"></vs-select>
  <vs-multiselect :options="options1"></vs-multiselect>
</template>

Nuxt Code Snippet

After installation,

  • Create a file /plugins/vs-select.js

    import Vue from 'vue';
    import { VsSelect, VsMultiselect } from 'vs-select';
    
    Vue.component('vs-select', VsSelect);
    Vue.component('vs-select', VsMultiselect);
  • Update nuxt.config.js

    module.exports = {
      ...
      plugins: [
        { src: '~plugins/vs-select', mode: 'client' }
        ...
      ]
    }
  • In the page/ component

    <template>
      <vs-select :options="options1"></vs-select>
      <vs-multiselect :options="options1"></vs-multiselect>
    </template>

🔥 Customizable

<vs-select :options="options1" is-search>
  <template v-slot:options="{ options, selected, onSelectedItem }">
    <li
      v-for="(option, index) in options"
      :key="'selected-' + index"
      class="menu-item"
      :class="[{ 'menu-item--is-checked': selected === option }]"
      @click="onSelectedItem(option, index)"
    >
      <span>{{ option }}</span>
    </li>
  </template>
</vs-select>

⚙ Props

NameTypeDefaultDescription
optionsArray-This can be array or array of objects. ['Tony', 'Bruce'] or [{ label: 'Derek', value: 'D' }],
isSearchBooleanfalseSearchable select
labelString'Select'Placeholder text
preselectedArray-Preselected items. For array of objects, pass value as array items ex: ['D', 'BB']
disabledBooleanfalseTo disable select box
isErrorBooleanfalseTo show error in select box
isMenuBooleanfalseTo display like menu dropdown. Available only on vs-select
isCompactBooleanfalseApplies compact style to vs-select
emptyItemsTextStringNo Data AvailableEmpty text

Note You can also pass disable: true in array of objects to disable particular item.

// Example
<template>
  <vs-select :options="options"></vs-select>
</template>

<script>
  import { VsSelect } from 'vs-select';

  export default {
    data() {
      return {
        options: [
          { label: 'Iron Man', value: 'Tony' },
          { label: 'Thor', value: 'thor', disabled: true },
          { label: 'Captain America', value: 'Steve Roger' },
        ],
      };
    },
  };
</script>

🔥 Events

NameDescription
v-modelEmitted when the item is selected.
onSelectEmitted when the item is selected.

📎 Slots

You can define own item markup via slots:

NameDescription
defaultHolds the label area
optionsHolds the select option content and can contain HTML.Slot data options, selected (Array), selectedObject(Array of Objects), onSelectedItemCheck CodeSandbox for examples

Note Colors/ radius can be modified for the select box using css variables. Default colors used:

<style>
  .vs-select,
  .vs-multiselect {
    --vs-select-bg: #ffffff;
    --vs-select-border: #d8dcde;
    --vs-select-border-hover: #5293c7;
    --vs-select-hover: #edf7ff;
    --vs-select-error: #cc3340;
    --vs-select-icon: #68737d;
    --vs-select-border-radius: 4px;
  }
</style>
1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

0.9.6

3 years ago

0.9.5

3 years ago

0.9.4

3 years ago

0.9.3

3 years ago

0.9.2

3 years ago

0.9.1

3 years ago

0.9.0

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0-beta.6

3 years ago

0.1.0-beta.3

3 years ago

0.1.0-beta.5

3 years ago

0.1.0-beta.4

3 years ago

0.1.0-beta.2

3 years ago

0.1.0-beta.1

3 years ago

0.0.0

8 years ago