Select

Allow users to choose from a list of options.

Preview
Code

Basic Example

<script>
	import { Select, SelectTrigger, SelectContent SelectOption, SelectValue } from 'lithesome';

	let value = $state();
</script>

<Select bind:value>
	<SelectTrigger>
		<SelectValue />
	</SelectTrigger>
	<SelectContent>
		<SelectOption value="item-1">Item 1</SelectOption>
		<SelectOption value="item-2">Item 2</SelectOption>
		<SelectOption value="item-3">Item 3</SelectOption>
	</SelectContent>
</Select>

API Reference

<Select />

PropertyTypeDescription
value V

The currently selected option(s).

multiple boolean

Allows multiple options to be selected at once.

onValueChanged (value: V) => void

Fires whenever the `value` prop changes.

children Snippet<[ S extends Record<string, any> ? S : never ]>

The default snippet to render.

visible boolean

The current visibility of the contents.

disabled boolean

Disables the entire component tree.

portalTarget HTMLElement | string

The DOM target to mount the content to.

floatingConfig FloatingConfig

The underlying FloatingUI config.

StateTypeDescription
visiblebooleanTrue if the contents are visible.

<SelectTrigger />

PropertyTypeDescription
ref E

The reference to the underlying element.

children Snippet<[ S extends Record<string, any> ? S : never ]>

The default snippet to render.

custom Snippet<[ S extends Record<string, any> ? { props: P; state: S; } : { props: P; } ]>

Snippet to be used when wanting a custom implementation. This will tell Lithesome not the render the default element and any state along with it.

StateTypeDescription
visiblebooleanTrue if the contents are visible.

<SelectContent />

PropertyTypeDescription
ref E

The reference to the underlying element.

children Snippet<[ S extends Record<string, any> ? S : never ]>

The default snippet to render.

custom Snippet<[ S extends Record<string, any> ? { props: P; state: S; } : { props: P; } ]>

Snippet to be used when wanting a custom implementation. This will tell Lithesome not the render the default element and any state along with it.

StateTypeDescription
visiblebooleanTrue if the contents are visible.

<SelectArrow />

PropertyTypeDescription
ref E

The reference to the underlying element.

children Snippet<[ S extends Record<string, any> ? S : never ]>

The default snippet to render.

custom Snippet<[ S extends Record<string, any> ? { props: P; state: S; } : { props: P; } ]>

Snippet to be used when wanting a custom implementation. This will tell Lithesome not the render the default element and any state along with it.

StateTypeDescription
visiblebooleanTrue if the contents are visible.

<SelectOption />

PropertyTypeDescription
value JsonValue

The value of the option.

disabled boolean

Disables the option, skipping mouse/keyboard navigation and stopping events from firing.

label string

The label to be display on the option and if this option is selected. If this prop is not provided, the text content of the option is used.

ref E

The reference to the underlying element.

children Snippet<[ S extends Record<string, any> ? S : never ]>

The default snippet to render.

custom Snippet<[ S extends Record<string, any> ? { props: P; state: S; } : { props: P; } ]>

Snippet to be used when wanting a custom implementation. This will tell Lithesome not the render the default element and any state along with it.

StateTypeDescription
hoveredbooleanTrue if the option is hovered.
selectedbooleanTrue if the option is selected.

<SelectValue />

PropertyTypeDescription
placeholder string

The value displayed when no option(s) is selected.

ref E

The reference to the underlying element.

StateTypeDescription
visiblebooleanTrue if the contents are visible.
placeholderVisiblebooleanTrue if no options are selected.