
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
svelte-multiselect
Advanced tools
Keyboard-friendly, zero-dependency MultiSelect
Svelte component.
single
prop to only allow one selectionwindow
or document
yarn add -D svelte-multiselect
<script>
import MultiSelect from 'svelte-multiselect'
const webFrameworks = [`Svelte`, `React`, `Vue`, `Angular`, `Polymer`, `Ruby on Rails`, `ASP.net`, `Laravel`, `Django`, `Express`, `Spring`]
const name = `webFrameworks`
const placeholder = `Take your pick...`
const required = true
let selected
</script>
Favorite Web Frameworks?
<MultiSelect bind:selected {name} {placeholder} options={webFrameworks} {required} />
Full list of props/bindable variables for this component:
name | default | description |
---|---|---|
options | [required] | Array of strings (or integers) that will be listed in the dropdown selection. |
selected | [] | Array of currently/pre-selected options when binding/passing as props respectively. |
readonly | false | Disables the input. User won't be able to interact with it. |
placeholder | '' | String shown when no option is selected. |
single | false | Allows only a single option to be selected when true. |
required | false | Prevents submission in an HTML form when true. |
input | undefined | Handle to the DOM node storing the currently selected options in JSON format as its value attribute. |
name | '' | Used as reference for associating HTML form labels with this component as well as for the input id . That is, the same DOM node input bindable through <MultiSelect bind:input /> is also retrievable via document.getElementByID(name) e.g. for use in a JS file outside a Svelte component. |
Clone the repo, install dev dependencies and start the dev server to test your changes before submitting a PR.
git clone https://github.com/janosh/svelte-multiselect
cd svelte-multiselect
yarn
yarn dev
You can style every part of this component by using the following selectors. Overriding properties that the component already sets internally requires the !important
keyword.
:global(.multiselect) {
/* top-level wrapper div */
}
:global(.multiselect span.token) {
/* selected options */
}
:global(.multiselect span.token button),
:global(.multiselect .remove-all) {
/* buttons to remove a single or all selected options at once */
}
:global(.multiselect ul) {
/* dropdown options */
}
:global(.multiselect ul li) {
/* dropdown options */
}
:global(li.selected) {
/* selected options in the dropdown list */
}
:global(li:not(.selected):hover) {
/* unselected but hovered options in the dropdown list */
}
:global(li.selected:hover) {
/* selected and hovered options in the dropdown list */
/* probably not necessary to style this state in most cases */
}
:global(li.active) {
/* active means element was navigated to with up/down arrow keys */
/* ready to be selected by pressing enter */
}
:global(li.selected.active) {
}
FAQs
Svelte multi-select component
The npm package svelte-multiselect receives a total of 7,928 weekly downloads. As such, svelte-multiselect popularity was classified as popular.
We found that svelte-multiselect demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.