Select
A custom dropdown with labels, placeholder, helper text, and validation states. The options property is set
via JavaScript as an array of { value, label } objects.
Each option may also include an optional group (groups a contiguous run of options under one
heading, like a native <optgroup>), icon, and description.
Playground
Usage
<lt-select id="my-select" label="Country" placeholder="Select a country"></lt-select>
<script type="module">
const select = document.getElementById('my-select');
select.options = [
{ value: 'us', label: 'United States' },
{ value: 'gb', label: 'United Kingdom' },
{ value: 'ca', label: 'Canada' },
];
select.addEventListener('change', (e) => console.log(e.detail.value));
</script>
<!-- Multiple selection: value is an array of the selected values -->
<lt-select id="fruit" label="Fruit" multiple></lt-select>
<!-- clearable: shows a clear button once a value is selected -->
<lt-select id="clearable-select" label="Country" clearable></lt-select>
<!-- loading: shows a spinner in place of the option list, for async-fetched options -->
<lt-select id="loading-select" label="Country" loading></lt-select>
<!-- Option groups, descriptions, and icons: options sharing a "group" render under one heading (consecutive
entries only, like a native <optgroup>); "description" and "icon" are both optional, per option -->
<lt-select id="grouped-select" label="Country"></lt-select>
<script type="module">
document.getElementById('grouped-select').options = [
{ value: 'us', label: 'United States', group: 'North America', icon: 'globe' },
{ value: 'ca', label: 'Canada', group: 'North America' },
{ value: 'gb', label: 'United Kingdom', group: 'Europe' },
{ value: 'fr', label: 'France', group: 'Europe', description: 'Eiffel Tower, croissants' }
];
</script>
import { Select } from '@latty-ds/react';
const options = [
{ value: 'us', label: 'United States' },
{ value: 'gb', label: 'United Kingdom' },
{ value: 'ca', label: 'Canada' },
];
<Select
label="Country"
placeholder="Select a country"
options={options}
onChange={(e) => console.log(e.detail.value)}
/>
// Multiple selection: value is an array of the selected values
<Select label="Fruit" multiple />
// clearable: shows a clear button once a value is selected
<Select label="Country" clearable />
// loading: shows a spinner in place of the option list, for async-fetched options
<Select label="Country" loading />
// Option groups, descriptions, and icons: options sharing a "group" render under one heading
// (consecutive entries only, like a native <optgroup>); "description" and "icon" are both optional
const groupedOptions = [
{ value: 'us', label: 'United States', group: 'North America', icon: 'globe' },
{ value: 'ca', label: 'Canada', group: 'North America' },
{ value: 'gb', label: 'United Kingdom', group: 'Europe' },
{ value: 'fr', label: 'France', group: 'Europe', description: 'Eiffel Tower, croissants' }
];
<Select label="Country" options={groupedOptions} />
<script setup lang="ts">
const options = [
{ value: 'us', label: 'United States' },
{ value: 'gb', label: 'United Kingdom' },
{ value: 'ca', label: 'Canada' },
]
const groupedOptions = [
{ value: 'us', label: 'United States', group: 'North America', icon: 'globe' },
{ value: 'ca', label: 'Canada', group: 'North America' },
{ value: 'gb', label: 'United Kingdom', group: 'Europe' },
{ value: 'fr', label: 'France', group: 'Europe', description: 'Eiffel Tower, croissants' }
]
</script>
<template>
<lt-select
label="Country"
placeholder="Select a country"
:options="options"
@change="(e) => console.log(e.detail.value)"></lt-select>
<!-- clearable: shows a clear button once a value is selected -->
<lt-select label="Country" clearable></lt-select>
<!-- loading: shows a spinner in place of the option list, for async-fetched options -->
<lt-select label="Country" loading></lt-select>
<!-- Option groups, descriptions, and icons: options sharing a "group" render under one heading
(consecutive entries only, like a native <optgroup>); "description" and "icon" are both optional -->
<lt-select label="Country" :options="groupedOptions"></lt-select>
</template>
Select vs. Dropdown
Both let the user choose from a list of options, but they are built for different purposes:
| Select | Dropdown | |
|---|---|---|
| Trigger | A styled form field with a label and helper text | Any slotted element — button, icon, avatar |
| Options |
| Fully custom slot content ( |
| Use when | Form fields — the user is selecting a value that will be submitted or stored | Action menus, context menus, overflow menus — the user is choosing an action, not setting a value |
| Avoid when | You need fully custom item layouts beyond a label/description/icon, or the trigger isn't a form field | You need the selected value to persist or participate in form submission — use Select instead |