slim-select
TypeScript icon, indicating that this package has built-in type declarations

2.12.1 • Public • Published

Slim Select 2

Advanced select dropdown

NPM Downloads GitHub Actions Workflow Status slim-select

Support

Buy Me A Coffee

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

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'
import 'slim-select/styles' // optional css import method

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,
    focusSearch: 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',
    addableText: 'Press "Enter" to add {value}',
  },
})

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 | Error
    beforeChange: (newVal: Option[], oldVal: Option[]) => boolean | void
    afterChange: (newVal: Option[]) => void
    beforeOpen: () => void
    afterOpen: () => void
    beforeClose: () => void
    afterClose: () => void
    error: (err: Error) => void
  },
})

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
2.12.112,187latest

Version History

VersionDownloads (Last 7 Days)Published
2.12.112,187
2.12.0355
2.11.03,539
2.10.04,121
2.9.22,319
2.9.13
2.9.0460
2.8.22,239
2.8.1359
2.8.017
2.7.1522
2.7.028
2.6.04,152
2.5.192
2.5.0255
2.4.5102
2.4.419
2.4.34
2.4.232
2.4.18
2.4.03
2.3.3214
2.3.213
2.3.13
2.3.07
2.2.311
2.2.23
2.2.116
2.2.03
2.1.05
2.0.25
2.0.111
2.0.012
1.27.18,773
1.27.0466
1.26.2166
1.26.1188
1.26.0827
1.25.020
1.24.05
1.23.130
1.23.024
1.22.07
1.21.13
1.21.03
1.20.03
1.19.03
1.18.143
1.18.135
1.18.123
1.18.113
1.18.103
1.18.93
1.18.83
1.18.73
1.18.63
1.18.53
1.18.43
1.18.33
1.18.23
1.18.13
1.18.03
1.17.03
1.16.03
1.15.13
1.15.03
1.14.03
1.13.03
1.12.13
1.12.03
1.11.23
1.11.13
1.11.02
1.10.03
1.9.03
1.8.13
1.8.03
1.7.03
1.6.23
1.6.13
1.6.03
1.5.23
1.5.13
1.4.33
1.4.24
1.4.14
1.4.03
1.3.23
1.3.13
1.3.03
1.2.03
1.1.53
1.1.43
1.1.33
1.1.23
1.1.13
1.1.03
1.0.03
0.11.23
0.11.13
0.11.02
0.10.02
0.9.12
0.9.02
0.8.02
0.7.02
0.6.02
0.5.02
0.4.12
0.4.02
0.3.12
0.3.02
0.2.02
0.1.02

Package Sidebar

Install

npm i slim-select

Weekly Downloads

41,827

Version

2.12.1

License

MIT

Unpacked Size

770 kB

Total Files

48

Last publish

Collaborators

  • brianvoe