Skip to content

Autocomplete

<loomi-autocomplete> is a text field with a suggestion panel. It follows the same spacing, borders, focus ring, labels, and dark-mode tokens as <loomi-input> and <loomi-select>.

Terminal window
npm install @loomidev/autocomplete lit
import "@loomidev/autocomplete";

Assign suggestions as a JavaScript property, then listen for loomi-select.

<loomi-autocomplete label="Assignee" placeholder="Search teammates"></loomi-autocomplete>
<script type="module">
const field = document.querySelector("loomi-autocomplete");
field.data = [
{ label: "Ada Lovelace", value: "ada", description: "Engineering", image: "/avatars/ada.jpg" },
{ label: "Grace Hopper", value: "grace", description: "Platform", image: "/avatars/grace.jpg" },
{ label: "Katherine Johnson", value: "katherine", description: "Analytics" },
];
field.addEventListener("select", (event) => console.log(event.detail));
</script>

When an option is selected, the field displays the option label and optional image. The component value remains the option value, and that value is what gets submitted with a form.

Use variant="minimal" for a bottom-border-only field:

<loomi-autocomplete variant="minimal" placeholder="Search people"></loomi-autocomplete>

Use label-position="inside" to keep a compact label inside the top of the field, with the entered text displayed beneath it:

<loomi-autocomplete label="Assignee" label-position="inside"></loomi-autocomplete>

The input announces itself as a list autocomplete, keeps keyboard navigation inside the suggestion list, and emits a normal change event when a value is chosen. Users can type freely, use Up/Down to move through suggestions, press Enter to select, and press Escape to close the panel.

For the library-wide baseline, see Foundations — Accessibility.

The field fills its container, truncates long option labels, and keeps descriptions on one readable line so the panel remains compact in forms, modals, and narrow layouts.

For the shared container and viewport rules, see Foundations — Responsive behavior.

The field, panel, borders, hover states, and focus ring use Loomi semantic tokens, so they follow the app theme and .dark mode without custom overrides.

For theme activation, token overrides, and contrast guidance, see Foundations — Dark mode.

AttributeDefaultDescription
label(blank)Floating label text.
label-positiondefaultdefault keeps the floating label; inside keeps a compact label inside the top of the field.
placeholderSearch...Placeholder when no label is shown.
selected-value(blank)Sets the submitted value; matching options display their label and image.
sizemediumtiny | small | regular | medium | big.
variantdefaultdefault | minimal (bottom border only, no box)
label-keylabelProperty name for option labels.
value-keyvalueProperty name for submitted values.
description-keydescriptionProperty name for helper text.
image-keyimageProperty name for optional option images.
requiredfalseMarks the field required.
disabledfalseDisables input and selection.
readonlyfalsePrevents edits.
show-focus-ringtrueSet show-focus-ring="false" to hide the focus halo.
clearabletrueRead-only — always on. Shows an × button once the field has a value; clicking it empties the field and reopens the panel.
EventDetail
loomi-select{ item, value, label }
inputNative input event.
changeNative change event after selection.
  • @loomidev/core
  • @loomidev/icons