Select
A value and a button to open/close a list of choices.
Code
<script lang="ts">
import { Select, ListItem } from '@geoffcox/sterling-svelte';
let selectedValue : string;
let items = [/* list of items */];
</script>
<Select bind:selectedValue>
{#each items as item}
<ListItem value={item} />
{/each}
</Select>
Members
| Property Name | Type | Default | Comment |
---|
| disabled | boolean | null | undefined | false |
| icon | Snippet | undefined | undefined |
| listClass | string | undefined | undefined |
| onPending | (value: string) => void | undefined |
| onSelect | (value: string) => void | undefined |
| open | boolean | null | undefined | false |
| selectedValue | string | undefined | undefined |
| value | Snippet<[string | undefined]> | string | undefined | undefined |
| buttonSnippet | Snippet | undefined | undefined |
| valueSnippet | Snippet<[string | undefined]> | undefined | undefined |
| Method Name | Parameters | Return Type | Comment |
---|
| scrollToSelectedItem | | |
Considerations
- Due to lack of styling capabilities with <select>, the Select component does not use <select>
- Includes HTMLDivElement props, events, and methods.
Anatomy
<div class="sterling-select">
<div class="value">
{@render value()}
</div>
<div class="icon">
{@render icon()}
</div>
<Popover>
<div class="sterling-select-popup-content">
<List>
{@render children()}
</List>
</div>
</Popover>
</div>