2.8.2 • Published 2 months ago

slim-select v2.8.2

Weekly downloads
7,270
License
MIT
Repository
github
Last release
2 months ago

Slim Select 2

slimselectjs.com

Advanced select dropdown

NPM Downloads

Support

npm.io

Documentation and Examples

See website for the full list of settings, methods and event callbacks

npm.io

Features

  • No Dependencies
  • JS: 29kb - 5kb gzip
  • CSS: 7kb - 1kb gzip
  • Single Select
  • Multi Select
  • User Addable Options
  • Html Options
  • Settable Data
  • Callback Events
  • Placeholders
  • Search
  • Disable Options
  • Light CSS
  • Light Color Scheme
  • Style and Class Inheritance
  • Clean Animations
  • Performant
  • Typescript

Frameworks

  • Vue

Installation

npm install slim-select

or

<script src="https://unpkg.com/slim-select@latest/dist/slimselect.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/slim-select@latest/dist/slimselect.css" />

Simple Usage

import SlimSelect from 'slim-select'

new SlimSelect({
  select: '#selectElement',
})
<select id="selectElement">
  <option value="value1">Value 1</option>
</select>

Data

Data is an array of objects that represent both option and optgroups.

See below for list of data types

new SlimSelect({
  select: '#selectElement',

  // Array of Option objects
  data: [{ text: 'Value 1', value: 'value1' }],

  // or

  // Array of Optgroups and/or Options
  data: [{ label: 'Optgroup Label', options: { text: 'Value 1', value: 'value1' } }],
})

Data Types

// <optgroup>
var optgroup = {
  label: 'label', // Required
  selectAll: false, // Optional - default false
  closable: 'off', // Optional - default 'off' - 'off', 'open', 'close'
  options: [], // Required - value is an array of options
}

// <option>
var option = {
  text: 'text', // Required
  value: 'value', // Optional - value will be set by text if not set
  html: '<b>Html</b>', // Optional - if set, used for display purposes
  selected: false, // Optional - default is false
  display: true, // Optional - default is true
  disabled: false, // Optional - default is false
  mandatory: false, // Optional - default is false
  placeholder: false, // Optional - default is false
  class: '', // Optional - default is not set
  style: '', // Optional - default is not set
  data: {}, // Optional - If you have data attributes
}

Settings

Settings are a list of fields that help customize how SlimSelect operates

new SlimSelect({
  select: '#selectElement',

  settings: {
    // Below are a list of optional fields
    // their values are the defaults
    disabled: false,
    alwaysOpen: false,
    showSearch: true,
    searchPlaceholder: 'Search',
    searchText: 'No Results',
    searchingText: 'Searching...',
    searchHighlight: false,
    closeOnSelect: true,
    contentLocation: document.body,
    contentPosition: 'absolute',
    openPosition: 'auto', // options: auto, up, down
    placeholderText: 'Select Value',
    allowDeselect: false,
    hideSelected: false,
    showOptionTooltips: false,
    minSelected: 0,
    maxSelected: 1000,
    timeoutDelay: 200,
    maxValuesShown: 20,
    maxValuesMessage: '{number} selected',
  },
})

Events

Events are function callbacks for when certain actions happen

new SlimSelect({
  select: '#selectElement',

  events: {
    search: (searchValue: string, currentData: DataArray) => Promise<DataArrayPartial> | DataArrayPartial
    searchFilter: (option: Option, search: string) => boolean
    addable: (value: string) => Promise<OptionOptional | string> | OptionOptional | string
    beforeChange: (newVal: Option[], oldVal: Option[]) => boolean | void
    afterChange: (newVal: Option[]) => void
    beforeOpen: () => void
    afterOpen: () => void
    beforeClose: () => void
    afterClose: () => void
    error: (err: Error) => void
  },
})
2.8.2

2 months ago

2.8.1

4 months ago

2.8.0

4 months ago

2.7.1

5 months ago

2.7.0

5 months ago

2.6.0

10 months ago

2.5.1

11 months ago

2.4.1

1 year ago

2.4.3

1 year ago

2.4.2

1 year ago

2.4.5

1 year ago

2.4.4

1 year ago

2.5.0

12 months ago

2.2.1

1 year ago

2.2.0

1 year ago

2.0.2

1 year ago

2.2.3

1 year ago

2.4.0

1 year ago

2.2.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

2.3.0

1 year ago

2.3.2

1 year ago

2.3.1

1 year ago

2.3.3

1 year ago

2.1.0

1 year ago

1.27.1

2 years ago

1.27.0

3 years ago

1.26.2

3 years ago

1.26.1

3 years ago

1.26.0

4 years ago

1.25.0

4 years ago

1.24.0

4 years ago

1.23.1

5 years ago

1.23.0

5 years ago

1.22.0

5 years ago

1.21.1

5 years ago

1.21.0

5 years ago

1.20.0

5 years ago

1.19.0

5 years ago

1.18.14

5 years ago

1.18.13

5 years ago

1.18.12

5 years ago

1.18.11

5 years ago

1.18.10

5 years ago

1.18.9

5 years ago

1.18.8

5 years ago

1.18.7

5 years ago

1.18.6

6 years ago

1.18.5

6 years ago

1.18.4

6 years ago

1.18.3

6 years ago

1.18.2

6 years ago

1.18.1

6 years ago

1.18.0

6 years ago

1.17.0

6 years ago

1.16.0

6 years ago

1.15.1

6 years ago

1.15.0

6 years ago

1.14.0

6 years ago

1.13.0

6 years ago

1.12.1

6 years ago

1.12.0

6 years ago

1.11.2

6 years ago

1.11.1

6 years ago

1.11.0

6 years ago

1.10.0

6 years ago

1.9.0

6 years ago

1.8.1

6 years ago

1.8.0

6 years ago

1.7.0

6 years ago

1.6.2

6 years ago

1.6.1

6 years ago

1.6.0

6 years ago

1.5.2

6 years ago

1.5.1

6 years ago

1.4.3

6 years ago

1.4.2

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.2

6 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago

0.11.2

7 years ago

0.11.1

7 years ago

0.11.0

7 years ago

0.10.0

7 years ago

0.9.1

7 years ago

0.9.0

7 years ago

0.8.0

7 years ago

0.7.0

7 years ago

0.6.0

7 years ago

0.5.0

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago