Skip to content
iv-ui v0.3.0

Select

since 0.1.0

A custom listbox with search, multiple selection, and clearing.

import { Select } from '@elluzion/iv-ui';

Basic

A labelled single select with a placeholder.

Deploys use the selected branch.

Source· svelte Show Hide
<script lang="ts">
	import { Select } from '@elluzion/iv-ui';

	let branch = $state('');
</script>

<div class="field-row">
	<Select
		label="Branch"
		placeholder="Choose a branch"
		options={['main', 'release', 'feat/docs-site']}
		bind:value={branch}
		helper="Deploys use the selected branch."
	/>
</div>

<style>
	.field-row {
		width: 100%;
		max-width: 320px;
	}
</style>
  • options accepts strings or { value, label, disabled }.
  • multiple turns value into an array; searchable adds a filter field.
  • Bind value; onchange fires with the committed selection.

Multiple

Selected values render as chips and value is an array.

Selected services receive the retention policy.

selected: logs, metrics

Source· svelte Show Hide
<script lang="ts">
	import { Select } from '@elluzion/iv-ui';

	let services = $state<string[]>(['logs', 'metrics']);
</script>

<div class="field-row">
	<Select
		label="Services"
		multiple
		options={['logs', 'metrics', 'traces', 'alerts', 'backups']}
		bind:value={services}
		helper="Selected services receive the retention policy."
	/>
	<p class="readout">selected: {services.join(', ') || '—'}</p>
</div>

<style>
	.field-row {
		display: flex;
		flex-direction: column;
		gap: var(--iv_spacing-md);
		width: 100%;
		max-width: 360px;
	}

	.readout {
		margin: 0;
		font-family: var(--iv_font-mono);
		font-size: var(--iv_text-sm);
		color: var(--iv_foreground-dim);
	}
</style>

Searchable

searchable filters the list as you type.

Source· svelte Show Hide
<script lang="ts">
	import { Select } from '@elluzion/iv-ui';

	let member = $state('');

	const options = [
		'Ada Lovelace',
		'Grace Hopper',
		'Alan Turing',
		'Katherine Johnson',
		'Margaret Hamilton',
		'Radia Perlman'
	];
</script>

<div class="field-row">
	<Select label="Reviewer" searchable placeholder="Search people…" {options} bind:value={member} />
</div>

<style>
	.field-row {
		width: 100%;
		max-width: 320px;
	}
</style>

States

Clearable, error, and disabled variants.

An environment is required.

Source· svelte Show Hide
<script lang="ts">
	import { Select } from '@elluzion/iv-ui';

	let region = $state('eu-west');
	let environment = $state('');
</script>

<div class="stack">
	<Select
		label="Region"
		clearable
		options={['eu-west', 'us-east', 'ap-south']}
		bind:value={region}
	/>
	<Select
		label="Environment"
		placeholder="Choose an environment"
		options={['staging', 'production']}
		bind:value={environment}
		error="An environment is required."
	/>
	<Select label="Organization" options={['orbital']} value="orbital" disabled />
</div>

<style>
	.stack {
		display: flex;
		flex-direction: column;
		gap: var(--iv_spacing-lg);
		width: 100%;
		max-width: 320px;
	}
</style>
import { Select } from '@elluzion/iv-ui';

Props

13 props · 4 events · 0 snippets
PropTypeDefaultDescription
options required SelectOption[][]Options to render. Strings are used as both value and label.
value bindablestring | string[]''Selected value(s). Bind with bind:value.
multiple booleanfalseAllows several values; value becomes an array.
searchable booleanfalseAdds a filter field to the option list.
clearable booleanfalseShows a reset button while a value is selected.
disabled booleanfalseDisables interaction and applies the disabled treatment.
required booleanfalseMarks the field as required.
placeholder string'Select…'Text shown while nothing is selected.
label string''Visible label for the control.
error string''Error message. Switches the control to the error treatment.
helper string''Helper text shown below the control.
name string''Form field name submitted with the surrounding form.
size 'sm' | 'md' | 'lg''md'Control size.

Events

EventHandler typeDescription
onchange(e: CustomEvent<{ value: string | string[] }>) => voidCalled with { value } after the selection changes.
onfocus(e: FocusEvent) => voidCalled when the trigger receives focus.
onblur(e: FocusEvent) => voidCalled when the trigger loses focus.
onkeydown(e: KeyboardEvent) => voidCalled on keydown inside the trigger.

The legacy on:name form is accepted for every event.

Types

SelectOption

An option value or a full option object.

type SelectOption = string | { value: string; label?: string; disabled?: boolean };
KeysAction
Enter / Space / ArrowDownOpens the list.
Arrow keysMove the active option.
EnterSelects the active option.
EscapeCloses the list.
  • The trigger is a combobox with aria-expanded, aria-controls, and aria-activedescendant.
  • Options use the option role inside a listbox.
  • Error text is linked through aria-describedby; the trigger gets aria-invalid.
Class hooks
.iv-chevron.iv-chip.iv-chip-placeholder.iv-chips.iv-clear-btn.iv-disabled.iv-dropdown.iv-error-message.iv-has-error.iv-helper-message.iv-label.iv-lg.iv-message.iv-open.iv-placeholder.iv-required-mark.iv-root.iv-search.iv-search-icon.iv-select-options.iv-sm.iv-trigger.iv-trigger-label
iv-ui
↑ ↓ navigate ↵ open esc close minisearch · 482 records