svelte-select (demo)
A select component for Svelte apps.
Installation
yarn add svelte-select
Usage
<Select {items}></Select>
<script>
import Select from 'svelte-select';
export default {
components: { Select },
data() {
return {
items: [
{value: 'chocolate', label: 'Chocolate'},
{value: 'pizza', label: 'Pizza'},
{value: 'cake', label: 'Cake'},
{value: 'chips', label: 'Chips'},
{value: 'ice-cream', label: 'Ice Cream'},
]
};
}
};
</script>
Development
yarn global add serve@8
yarn
yarn dev
Configuring webpack
If you're using webpack with svelte-loader, make sure that you add "svelte"
to resolve.mainFields
in your webpack config. This ensures that webpack imports the uncompiled component (src/index.html
) rather than the compiled version (index.mjs
) — this is more efficient.
If you're using Rollup with rollup-plugin-svelte, this will happen automatically.
License
LIL