Select

Select is a simple yet effective UI pattern for enabling users to make single-item selections from a list or set of options.

countries.ts

export let countries = [
	{ value: 'us', label: 'United States'},
	{ value: 'fr', label: 'France'},
	{ value: 'gb', label: 'United Kingdom' },
	{ value: 'de', label: 'Germany' },
	{ value: 'jp', label: 'Japan' },
	{ value: 'au', label: 'Australia' },
	{ value: 'cn', label: 'China' },
	{ value: 'in', label: 'India' },
	{ value: 'mx', label: 'Mexico' },
]

+page.svelte

<script lang="ts">import { countries } from "$lib/countries";
import { Select } from "@grampro/svelte-block";
let selected = void 0;
</script>

<div>
	<Select items={countries} bind:selected={selected} />
</div>

Sample

Nb: Style issue with svx may cause some abnormalities in the component preview style. Working to fix this.

Props

Property Type Description
placeholder String The placeholder text displayed when no item is selected.
items Array An array of items to populate the select dropdown.
selected Any The currently selected item.
lazy Boolean If set to true, the select component enables lazy loading of items.
showSearch Boolean Toggles the searchbar inside Select “on” and “off
searchboxClass String Style class for searchbox
popUpClass String Style for select dropdown
itemClass String Style for select items