Select
Allow users to choose from a list of options.
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 />
| Property | Type | Description |
|---|---|---|
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. |
| State | Type | Description |
|---|---|---|
visible | boolean | True if the contents are visible. |
<SelectTrigger />
| Property | Type | Description |
|---|---|---|
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. |
| State | Type | Description |
|---|---|---|
visible | boolean | True if the contents are visible. |
<SelectContent />
| Property | Type | Description |
|---|---|---|
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. |
| State | Type | Description |
|---|---|---|
visible | boolean | True if the contents are visible. |
<SelectArrow />
| Property | Type | Description |
|---|---|---|
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. |
| State | Type | Description |
|---|---|---|
visible | boolean | True if the contents are visible. |
<SelectOption />
| Property | Type | Description |
|---|---|---|
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. |
| State | Type | Description |
|---|---|---|
hovered | boolean | True if the option is hovered. |
selected | boolean | True if the option is selected. |
<SelectValue />
| Property | Type | Description |
|---|---|---|
placeholder | string | The value displayed when no option(s) is selected. |
ref | E | The reference to the underlying element. |
| State | Type | Description |
|---|---|---|
visible | boolean | True if the contents are visible. |
placeholderVisible | boolean | True if no options are selected. |