Skip to main content
Home pageComponentsSelect

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​

HTMLReact
ShareCopy

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:

SelectDropdown
TriggerA styled form field with a label and helper textAny slotted element — button, icon, avatar
Options

options prop — array of { value, label }, with optional group, icon, and description

Fully custom slot content (lt-dropdown-item)

Use whenForm fields — the user is selecting a value that will be submitted or storedAction menus, context menus, overflow menus — the user is choosing an action, not setting a value
Avoid whenYou need fully custom item layouts beyond a label/description/icon, or the trigger isn't a form fieldYou need the selected value to persist or participate in form submission — use Select instead

API​