Searchable Selects
A select with a search box: options from HTML, JSON or a paginated API, descriptions, hint, multiple selection, validation, states and the options reference. Each card can be collapsed.
Basic usage
A button that looks like a select opens a panel with a search box. options lists the choices as { value, text, description }; the description is a second line that is searched too. value sets the first choice. multiple allows several choices: each is a chip with its own remove button, a clear button empties the selection, and the form gets every value. The choice lives in a hidden native <select> that carries name, required, and disabled, so the form submits it as usual. With required, a submit without a choice focuses the button and shows the message. Reset returns every field to its first selection, and the form uses method="get", so after a valid submit the posted fields show in the address bar.
<form method="get" class="space-y-5">
<div class="grid grid-cols-1 gap-5 sm:grid-cols-2">
<div
id="searchable-static-category-field"
x-data='searchableSelect(Object.assign({"value":["books"]}, {}))'
x-on:focusout="onFocusOut($event)"
class="relative group/combo"
>
<div class="flex items-center gap-1 mb-1.5">
<label
id="searchable-static-category-label"
for="searchable-static-category"
class="block text-sm font-medium text-dominant-700 dark:text-dominant-200"
>
<span>Category</span>
<span aria-hidden="true" class="text-danger-700 dark:text-danger-300">*</span>
</label>
<button
id="searchable-static-category-hint-button"
type="button"
aria-controls="searchable-static-category-hint"
aria-expanded="false"
aria-haspopup="true"
aria-label="Hint for Category"
class="flex shrink-0 items-center justify-center size-6 text-dominant-600 dark:text-dominant-300 rounded-full cursor-pointer transition-colors peer hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-circle-question"> </i>
</button>
<div
id="searchable-static-category-hint"
class="absolute top-7 left-0 z-10 p-3 w-full max-w-xs text-sm text-dominant-700 dark:text-dominant-200 bg-white dark:bg-dominant-800 opacity-0 rounded-lg border border-dominant-200 dark:border-dominant-700 shadow-lg invisible scale-95 transition-all duration-150 origin-top-left peer-aria-expanded:visible peer-aria-expanded:scale-100 peer-aria-expanded:opacity-100"
>
<span>Choose the category this item belongs to. Type to search by name.</span>
</div>
</div>
<div class="relative">
<button
id="searchable-static-category"
class="block inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 pr-16 w-full text-dominant-900 dark:text-white text-left bg-white dark:bg-dominant-950 rounded-lg cursor-pointer placeholder:text-dominant-600 dark:placeholder:text-dominant-400 focus:inset-ring-primary-500 dark:focus:inset-ring-primary-400 focus:ring-2 focus:ring-primary-500/30 dark:focus:ring-primary-400/30 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:inset-ring-danger-600 dark:aria-invalid:inset-ring-danger-400 aria-invalid:focus:inset-ring-danger-600 dark:aria-invalid:focus:inset-ring-danger-400 aria-invalid:focus:ring-danger-600/30 dark:aria-invalid:focus:ring-danger-400/30 px-3.5 py-2.5 text-sm"
x-ref="trigger"
type="button"
aria-haspopup="listbox"
aria-controls="searchable-static-category-panel"
aria-expanded="false"
x-bind:aria-invalid="showError ? 'true' : null"
x-bind:aria-required="required ? 'true' : null"
x-bind:disabled="disabled"
x-on:click="onTrigger()"
x-on:keydown.down.prevent="onArrow()"
x-bind:aria-describedby="['searchable-static-category-hint', 'searchable-static-category-help', showError ? 'searchable-static-category-error' : null].filter(Boolean).join(' ') || null"
aria-labelledby="searchable-static-category-label searchable-static-category-value"
>
<span
id="searchable-static-category-value"
x-bind:class="hasValue ? '' : 'text-dominant-600 dark:text-dominant-400'"
data-placeholder="Select a category"
x-text="hasValue ? selected[0].text : $el.dataset.placeholder"
class="block truncate"
>Select a category</span
>
</button>
<button
type="button"
aria-label="Clear Category"
x-bind:hidden="!hasValue || disabled"
x-on:click="clear()"
class="absolute top-1/2 right-9 flex items-center justify-center size-6 text-xs text-dominant-600 dark:text-dominant-300 rounded-full cursor-pointer transition-colors -translate-y-1/2 hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
<i
aria-hidden="true"
class="absolute top-1/2 right-3.5 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-chevron-down"
>
</i>
</div>
<div
id="searchable-static-category-panel"
class="absolute z-10 mt-1 w-full bg-white dark:bg-dominant-800 rounded-lg border border-dominant-200 dark:border-dominant-700 opacity-0 shadow-lg invisible origin-top scale-95 transition-all duration-150 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:visible group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:scale-100 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:opacity-100"
>
<div class="p-2 border-b border-dominant-200 dark:border-dominant-700">
<div class="relative">
<i
aria-hidden="true"
class="absolute top-1/2 left-3 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-magnifying-glass"
>
</i>
<input
x-ref="search"
x-model="query"
type="text"
role="combobox"
autocomplete="off"
aria-autocomplete="list"
aria-expanded="true"
aria-controls="searchable-static-category-list"
x-bind:aria-activedescendant="activeId"
aria-label="Search Category"
placeholder="Search…"
x-on:input="onInput()"
x-on:keydown.down.prevent="move(1)"
x-on:keydown.up.prevent="move(-1)"
x-on:keydown.enter.prevent="onEnter()"
class="block inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 px-3 py-1.5 pl-9 w-full text-dominant-900 dark:text-white text-sm bg-white dark:bg-dominant-950 rounded-lg placeholder:text-dominant-600 dark:placeholder:text-dominant-400 focus:inset-ring-primary-500 dark:focus:inset-ring-primary-400 focus:ring-2 focus:ring-primary-500/30 dark:focus:ring-primary-400/30 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50"
/>
</div>
</div>
<div x-ref="scroller" x-on:scroll="onScroll($event)" class="overflow-y-auto max-h-60">
<ul
id="searchable-static-category-list"
role="listbox"
aria-labelledby="searchable-static-category-label"
class="p-1"
>
<template x-for="(option, index) in visible" x-bind:key="option.value">
<li
role="option"
x-bind:id="optionId(index)"
x-bind:aria-selected="String(isSelected(option))"
x-on:click="choose(option)"
x-on:mousemove="active = index"
x-bind:class="index === active ? 'bg-dominant-100 dark:bg-dominant-700' : ''"
class="flex items-center gap-3 px-3 py-2 text-sm text-dominant-900 dark:text-dominant-100 rounded-md cursor-pointer"
>
<span class="flex-1 min-w-0">
<span x-text="option.text" class="block truncate"> </span>
<template x-if="option.description">
<span
x-text="option.description"
class="block truncate text-xs text-dominant-600 dark:text-dominant-200"
>
</span>
</template>
</span>
<template x-if="isSelected(option)">
<i
aria-hidden="true"
class="text-xs text-dominant-900 dark:text-white fa-solid fa-check"
>
</i>
</template>
</li>
</template>
</ul>
<p
x-bind:hidden="!message"
class="flex items-center gap-2 px-3 py-2 text-sm text-dominant-600 dark:text-dominant-300"
>
<i
x-bind:hidden="!loading"
aria-hidden="true"
class="text-xs fa-solid fa-spinner fa-spin"
>
</i>
<span x-text="message"> </span>
<button
id="searchable-static-category-retry"
type="button"
x-bind:hidden="!error"
x-on:click="retry()"
class="font-semibold rounded underline-offset-2 focus-visible:ring-2 focus-visible:outline-none cursor-pointer text-primary-700 dark:text-primary-300 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 underline hover:text-primary-800 dark:hover:text-primary-200 ml-auto"
>
<span>Try again</span>
</button>
</p>
</div>
<p role="status" x-text="status" class="sr-only"></p>
</div>
<select
id="searchable-static-category-select"
name="category"
x-ref="select"
tabindex="-1"
aria-hidden="true"
required="true"
x-on:invalid.prevent="onInvalid($event)"
class="sr-only"
>
<option value="apparel" data-description="Clothing, shoes and accessories">Apparel</option>
<option value="books" data-description="Print books and audiobooks">Books</option>
<option value="electronics" data-description="Phones, computers and audio">
Electronics
</option>
<option value="furniture" data-description="Home and office furniture">Furniture</option>
<option value="garden" data-description="Plants, tools and outdoor living">Garden</option>
<option value="groceries" data-description="Food and everyday supplies">Groceries</option>
<option value="health" data-description="Wellness and personal care">Health</option>
<option value="sports" data-description="Equipment for training and outdoor activities">
Sports
</option>
<option value="toys" data-description="Games and toys for all ages">Toys</option>
<option value="travel" data-description="Luggage and travel accessories">Travel</option>
<template x-if="!multiple">
<option value x-bind:selected="!hasValue"></option>
</template>
<template x-for="item in selected" x-bind:key="item.value">
<option x-bind:value="item.value" selected x-text="item.text"></option>
</template>
</select>
<p
id="searchable-static-category-help"
class="mt-1.5 text-sm text-dominant-600 dark:text-dominant-300"
>
Shown on the product page and used in reports.
</p>
<template x-if="showError">
<p
id="searchable-static-category-error"
class="flex items-start gap-1.5 mt-1.5 text-sm font-medium text-danger-700 dark:text-danger-300"
>
<i aria-hidden="true" class="mt-0.5 fa-solid fa-circle-exclamation"> </i>
<span>Select an option.</span>
</p>
</template>
</div>
<div
id="searchable-static-categories-field"
x-data='searchableSelect(Object.assign({"multiple":true,"value":["apparel","garden","travel"]}, {}))'
x-on:focusout="onFocusOut($event)"
class="relative group/combo"
>
<div class="flex items-center gap-1 mb-1.5">
<label
id="searchable-static-categories-label"
for="searchable-static-categories"
class="block text-sm font-medium text-dominant-700 dark:text-dominant-200"
>
<span>Categories</span>
</label>
<button
id="searchable-static-categories-hint-button"
type="button"
aria-controls="searchable-static-categories-hint"
aria-expanded="false"
aria-haspopup="true"
aria-label="Hint for Categories"
class="flex shrink-0 items-center justify-center size-6 text-dominant-600 dark:text-dominant-300 rounded-full cursor-pointer transition-colors peer hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-circle-question"> </i>
</button>
<div
id="searchable-static-categories-hint"
class="absolute top-7 left-0 z-10 p-3 w-full max-w-xs text-sm text-dominant-700 dark:text-dominant-200 bg-white dark:bg-dominant-800 opacity-0 rounded-lg border border-dominant-200 dark:border-dominant-700 shadow-lg invisible scale-95 transition-all duration-150 origin-top-left peer-aria-expanded:visible peer-aria-expanded:scale-100 peer-aria-expanded:opacity-100"
>
<span
>Choose every category that applies. The panel stays open so you can pick several.</span
>
</div>
</div>
<div class="relative">
<div
class="h-10 flex flex-nowrap items-center gap-1.5 overflow-hidden inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 pr-16 pl-2.5 w-full bg-white dark:bg-dominant-950 rounded-lg focus-within:inset-ring-primary-500 dark:focus-within:inset-ring-primary-400 focus-within:ring-2 focus-within:ring-primary-500/30 dark:focus-within:ring-primary-400/30 has-[button[aria-invalid=true]]:inset-ring-danger-600 dark:has-[button[aria-invalid=true]]:inset-ring-danger-400 has-[button[aria-invalid=true]]:focus-within:inset-ring-danger-600 dark:has-[button[aria-invalid=true]]:focus-within:inset-ring-danger-400 has-[button[aria-invalid=true]]:focus-within:ring-danger-600/30 dark:has-[button[aria-invalid=true]]:focus-within:ring-danger-400/30"
>
<template x-for="item in chips" x-bind:key="item.value">
<span
class="relative z-1 inline-flex shrink items-center gap-1 py-0.5 pr-1 pl-2 min-w-0 text-sm font-medium text-dominant-900 dark:text-dominant-100 bg-dominant-200 dark:bg-dominant-700 rounded-md"
>
<span x-text="item.text" class="truncate"> </span>
<button
type="button"
x-bind:aria-label="'Remove ' + item.text"
x-on:click="remove(item)"
class="flex shrink-0 items-center justify-center size-5 text-xs rounded cursor-pointer transition-colors hover:bg-dominant-300 dark:hover:bg-dominant-600 focus-visible:ring-2 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
</span>
</template>
<template x-if="hiddenCount">
<span
aria-hidden="true"
x-text="'+' + hiddenCount"
class="inline-flex shrink-0 items-center px-2 py-0.5 text-sm font-medium text-dominant-900 dark:text-dominant-100 bg-dominant-200 dark:bg-dominant-700 rounded-md"
>
</span>
</template>
<button
id="searchable-static-categories"
class="flex-1 px-1 py-1 min-w-0 truncate text-left text-sm text-dominant-600 dark:text-dominant-400 bg-transparent rounded cursor-pointer focus:outline-none after:absolute after:inset-0 after:content-['']"
x-ref="trigger"
type="button"
aria-haspopup="listbox"
aria-controls="searchable-static-categories-panel"
aria-expanded="false"
x-bind:aria-invalid="showError ? 'true' : null"
x-bind:aria-required="required ? 'true' : null"
x-bind:disabled="disabled"
x-on:click="onTrigger()"
x-on:keydown.down.prevent="onArrow()"
x-bind:aria-describedby="['searchable-static-categories-hint', showError ? 'searchable-static-categories-error' : null].filter(Boolean).join(' ') || null"
aria-labelledby="searchable-static-categories-label"
>
<span
data-placeholder="Add a category…"
x-bind:class="{ 'sr-only': hasValue }"
x-text="hasValue ? summary : $el.dataset.placeholder"
>Add a category…</span
>
</button>
<button
type="button"
aria-label="Clear all Categories"
title="Clear all"
x-bind:hidden="!hasValue"
x-on:click="clear()"
class="absolute top-1/2 right-9 flex items-center justify-center size-6 text-xs text-dominant-600 dark:text-dominant-300 rounded-full cursor-pointer transition-colors -translate-y-1/2 hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
<i
aria-hidden="true"
class="absolute top-1/2 right-3.5 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-chevron-down"
>
</i>
</div>
</div>
<div
id="searchable-static-categories-panel"
class="absolute z-10 mt-1 w-full bg-white dark:bg-dominant-800 rounded-lg border border-dominant-200 dark:border-dominant-700 opacity-0 shadow-lg invisible origin-top scale-95 transition-all duration-150 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:visible group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:scale-100 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:opacity-100"
>
<div class="p-2 border-b border-dominant-200 dark:border-dominant-700">
<div class="relative">
<i
aria-hidden="true"
class="absolute top-1/2 left-3 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-magnifying-glass"
>
</i>
<input
x-ref="search"
x-model="query"
type="text"
role="combobox"
autocomplete="off"
aria-autocomplete="list"
aria-expanded="true"
aria-controls="searchable-static-categories-list"
x-bind:aria-activedescendant="activeId"
aria-label="Search Categories"
placeholder="Search…"
x-on:input="onInput()"
x-on:keydown.down.prevent="move(1)"
x-on:keydown.up.prevent="move(-1)"
x-on:keydown.enter.prevent="onEnter()"
class="block inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 px-3 py-1.5 pl-9 w-full text-dominant-900 dark:text-white text-sm bg-white dark:bg-dominant-950 rounded-lg placeholder:text-dominant-600 dark:placeholder:text-dominant-400 focus:inset-ring-primary-500 dark:focus:inset-ring-primary-400 focus:ring-2 focus:ring-primary-500/30 dark:focus:ring-primary-400/30 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50"
/>
</div>
</div>
<div x-ref="scroller" x-on:scroll="onScroll($event)" class="overflow-y-auto max-h-60">
<ul
id="searchable-static-categories-list"
role="listbox"
aria-labelledby="searchable-static-categories-label"
aria-multiselectable="true"
class="p-1"
>
<template x-for="(option, index) in visible" x-bind:key="option.value">
<li
role="option"
x-bind:id="optionId(index)"
x-bind:aria-selected="String(isSelected(option))"
x-on:click="choose(option)"
x-on:mousemove="active = index"
x-bind:class="index === active ? 'bg-dominant-100 dark:bg-dominant-700' : ''"
class="flex items-center gap-3 px-3 py-2 text-sm text-dominant-900 dark:text-dominant-100 rounded-md cursor-pointer"
>
<span class="flex-1 min-w-0">
<span x-text="option.text" class="block truncate"> </span>
<template x-if="option.description">
<span
x-text="option.description"
class="block truncate text-xs text-dominant-600 dark:text-dominant-200"
>
</span>
</template>
</span>
<template x-if="isSelected(option)">
<i
aria-hidden="true"
class="text-xs text-dominant-900 dark:text-white fa-solid fa-check"
>
</i>
</template>
</li>
</template>
</ul>
<p
x-bind:hidden="!message"
class="flex items-center gap-2 px-3 py-2 text-sm text-dominant-600 dark:text-dominant-300"
>
<i
x-bind:hidden="!loading"
aria-hidden="true"
class="text-xs fa-solid fa-spinner fa-spin"
>
</i>
<span x-text="message"> </span>
<button
id="searchable-static-categories-retry"
type="button"
x-bind:hidden="!error"
x-on:click="retry()"
class="font-semibold rounded underline-offset-2 focus-visible:ring-2 focus-visible:outline-none cursor-pointer text-primary-700 dark:text-primary-300 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 underline hover:text-primary-800 dark:hover:text-primary-200 ml-auto"
>
<span>Try again</span>
</button>
</p>
</div>
<p role="status" x-text="status" class="sr-only"></p>
</div>
<select
id="searchable-static-categories-select"
name="categories[]"
x-ref="select"
tabindex="-1"
aria-hidden="true"
multiple="true"
x-on:invalid.prevent="onInvalid($event)"
class="sr-only"
>
<option value="apparel" data-description="Clothing, shoes and accessories">Apparel</option>
<option value="books" data-description="Print books and audiobooks">Books</option>
<option value="electronics" data-description="Phones, computers and audio">
Electronics
</option>
<option value="furniture" data-description="Home and office furniture">Furniture</option>
<option value="garden" data-description="Plants, tools and outdoor living">Garden</option>
<option value="groceries" data-description="Food and everyday supplies">Groceries</option>
<option value="health" data-description="Wellness and personal care">Health</option>
<option value="sports" data-description="Equipment for training and outdoor activities">
Sports
</option>
<option value="toys" data-description="Games and toys for all ages">Toys</option>
<option value="travel" data-description="Luggage and travel accessories">Travel</option>
<template x-if="!multiple">
<option value x-bind:selected="!hasValue"></option>
</template>
<template x-for="item in selected" x-bind:key="item.value">
<option x-bind:value="item.value" selected x-text="item.text"></option>
</template>
</select>
<template x-if="showError">
<p
id="searchable-static-categories-error"
class="flex items-start gap-1.5 mt-1.5 text-sm font-medium text-danger-700 dark:text-danger-300"
>
<i aria-hidden="true" class="mt-0.5 fa-solid fa-circle-exclamation"> </i>
<span>Select an option.</span>
</p>
</template>
</div>
</div>
<div class="flex flex-wrap items-center gap-3">
<button
id="button-1963"
type="submit"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 bg-primary-600 text-white shadow-sm not-disabled:hover:bg-primary-700 not-disabled:active:bg-primary-800 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 gap-2 px-4 py-2.5 text-sm in-[.button-group-extra-small]:gap-1.5 in-[.button-group-extra-small]:px-2.5 in-[.button-group-extra-small]:py-1 in-[.button-group-extra-small]:text-xs in-[.button-group-small]:gap-1.5 in-[.button-group-small]:px-3 in-[.button-group-small]:py-1.5 in-[.button-group-small]:text-sm in-[.button-group-large]:gap-2 in-[.button-group-large]:px-5 in-[.button-group-large]:py-3 in-[.button-group-large]:text-base in-[.button-group-extra-large]:gap-2.5 in-[.button-group-extra-large]:px-6 in-[.button-group-extra-large]:py-3.5 in-[.button-group-extra-large]:text-lg"
>
<span>Submit</span>
</button>
<button
id="button-1976"
type="reset"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 inset-ring inset-ring-dominant-300 dark:inset-ring-dominant-600 bg-white dark:bg-dominant-800 text-dominant-700 dark:text-dominant-200 dark:shadow-none shadow-sm not-disabled:hover:bg-dominant-100 dark:not-disabled:hover:bg-dominant-700 not-disabled:hover:text-dominant-900 dark:not-disabled:hover:text-white not-disabled:active:bg-dominant-200 dark:not-disabled:active:bg-dominant-600 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 gap-2 px-4 py-2.5 text-sm in-[.button-group-extra-small]:gap-1.5 in-[.button-group-extra-small]:px-2.5 in-[.button-group-extra-small]:py-1 in-[.button-group-extra-small]:text-xs in-[.button-group-small]:gap-1.5 in-[.button-group-small]:px-3 in-[.button-group-small]:py-1.5 in-[.button-group-small]:text-sm in-[.button-group-large]:gap-2 in-[.button-group-large]:px-5 in-[.button-group-large]:py-3 in-[.button-group-large]:text-base in-[.button-group-extra-large]:gap-2.5 in-[.button-group-extra-large]:px-6 in-[.button-group-extra-large]:py-3.5 in-[.button-group-extra-large]:text-lg"
>
<span>Reset</span>
</button>
</div>
</form>
Sizes
The size attribute sets the height and text size of the control: small, medium (the default) or large. These are the same sizes as the input and select. A single select changes its trigger; a multiple select changes its field box.
Select an option.
Select an option.
Select an option.
Select an option.
Select an option.
Select an option.
<div class="grid grid-cols-1 gap-5 sm:grid-cols-3">
<div
id="searchable-size-small-field"
x-data="searchableSelect(Object.assign({}, {}))"
x-on:focusout="onFocusOut($event)"
class="relative group/combo"
>
<div class="flex items-center gap-1 mb-1.5">
<label
id="searchable-size-small-label"
for="searchable-size-small"
class="block text-sm font-medium text-dominant-700 dark:text-dominant-200"
>
<span>Small</span>
</label>
</div>
<div class="relative">
<button
id="searchable-size-small"
class="block inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 pr-16 w-full text-dominant-900 dark:text-white text-left bg-white dark:bg-dominant-950 rounded-lg cursor-pointer placeholder:text-dominant-600 dark:placeholder:text-dominant-400 focus:inset-ring-primary-500 dark:focus:inset-ring-primary-400 focus:ring-2 focus:ring-primary-500/30 dark:focus:ring-primary-400/30 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:inset-ring-danger-600 dark:aria-invalid:inset-ring-danger-400 aria-invalid:focus:inset-ring-danger-600 dark:aria-invalid:focus:inset-ring-danger-400 aria-invalid:focus:ring-danger-600/30 dark:aria-invalid:focus:ring-danger-400/30 px-3 py-1.5 text-sm"
x-ref="trigger"
type="button"
aria-haspopup="listbox"
aria-controls="searchable-size-small-panel"
aria-expanded="false"
x-bind:aria-invalid="showError ? 'true' : null"
x-bind:aria-required="required ? 'true' : null"
x-bind:disabled="disabled"
x-on:click="onTrigger()"
x-on:keydown.down.prevent="onArrow()"
x-bind:aria-describedby="[showError ? 'searchable-size-small-error' : null].filter(Boolean).join(' ') || null"
aria-labelledby="searchable-size-small-label searchable-size-small-value"
>
<span
id="searchable-size-small-value"
x-bind:class="hasValue ? '' : 'text-dominant-600 dark:text-dominant-400'"
data-placeholder="Select a category"
x-text="hasValue ? selected[0].text : $el.dataset.placeholder"
class="block truncate"
>Select a category</span
>
</button>
<button
type="button"
aria-label="Clear Small"
x-bind:hidden="!hasValue || disabled"
x-on:click="clear()"
class="absolute top-1/2 right-9 flex items-center justify-center size-6 text-xs text-dominant-600 dark:text-dominant-300 rounded-full cursor-pointer transition-colors -translate-y-1/2 hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
<i
aria-hidden="true"
class="absolute top-1/2 right-3.5 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-chevron-down"
>
</i>
</div>
<div
id="searchable-size-small-panel"
class="absolute z-10 mt-1 w-full bg-white dark:bg-dominant-800 rounded-lg border border-dominant-200 dark:border-dominant-700 opacity-0 shadow-lg invisible origin-top scale-95 transition-all duration-150 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:visible group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:scale-100 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:opacity-100"
>
<div class="p-2 border-b border-dominant-200 dark:border-dominant-700">
<div class="relative">
<i
aria-hidden="true"
class="absolute top-1/2 left-3 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-magnifying-glass"
>
</i>
<input
x-ref="search"
x-model="query"
type="text"
role="combobox"
autocomplete="off"
aria-autocomplete="list"
aria-expanded="true"
aria-controls="searchable-size-small-list"
x-bind:aria-activedescendant="activeId"
aria-label="Search Small"
placeholder="Search…"
x-on:input="onInput()"
x-on:keydown.down.prevent="move(1)"
x-on:keydown.up.prevent="move(-1)"
x-on:keydown.enter.prevent="onEnter()"
class="block inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 px-3 py-1.5 pl-9 w-full text-dominant-900 dark:text-white text-sm bg-white dark:bg-dominant-950 rounded-lg placeholder:text-dominant-600 dark:placeholder:text-dominant-400 focus:inset-ring-primary-500 dark:focus:inset-ring-primary-400 focus:ring-2 focus:ring-primary-500/30 dark:focus:ring-primary-400/30 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50"
/>
</div>
</div>
<div x-ref="scroller" x-on:scroll="onScroll($event)" class="overflow-y-auto max-h-60">
<ul
id="searchable-size-small-list"
role="listbox"
aria-labelledby="searchable-size-small-label"
class="p-1"
>
<template x-for="(option, index) in visible" x-bind:key="option.value">
<li
role="option"
x-bind:id="optionId(index)"
x-bind:aria-selected="String(isSelected(option))"
x-on:click="choose(option)"
x-on:mousemove="active = index"
x-bind:class="index === active ? 'bg-dominant-100 dark:bg-dominant-700' : ''"
class="flex items-center gap-3 px-3 py-2 text-sm text-dominant-900 dark:text-dominant-100 rounded-md cursor-pointer"
>
<span class="flex-1 min-w-0">
<span x-text="option.text" class="block truncate"> </span>
<template x-if="option.description">
<span
x-text="option.description"
class="block truncate text-xs text-dominant-600 dark:text-dominant-200"
>
</span>
</template>
</span>
<template x-if="isSelected(option)">
<i
aria-hidden="true"
class="text-xs text-dominant-900 dark:text-white fa-solid fa-check"
>
</i>
</template>
</li>
</template>
</ul>
<p
x-bind:hidden="!message"
class="flex items-center gap-2 px-3 py-2 text-sm text-dominant-600 dark:text-dominant-300"
>
<i
x-bind:hidden="!loading"
aria-hidden="true"
class="text-xs fa-solid fa-spinner fa-spin"
>
</i>
<span x-text="message"> </span>
<button
id="searchable-size-small-retry"
type="button"
x-bind:hidden="!error"
x-on:click="retry()"
class="font-semibold rounded underline-offset-2 focus-visible:ring-2 focus-visible:outline-none cursor-pointer text-primary-700 dark:text-primary-300 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 underline hover:text-primary-800 dark:hover:text-primary-200 ml-auto"
>
<span>Try again</span>
</button>
</p>
</div>
<p role="status" x-text="status" class="sr-only"></p>
</div>
<select
id="searchable-size-small-select"
name="size-small"
x-ref="select"
tabindex="-1"
aria-hidden="true"
x-on:invalid.prevent="onInvalid($event)"
class="sr-only"
>
<option value="apparel">Apparel</option>
<option value="books">Books</option>
<option value="shoes">Shoes</option>
<template x-if="!multiple">
<option value x-bind:selected="!hasValue"></option>
</template>
<template x-for="item in selected" x-bind:key="item.value">
<option x-bind:value="item.value" selected x-text="item.text"></option>
</template>
</select>
<template x-if="showError">
<p
id="searchable-size-small-error"
class="flex items-start gap-1.5 mt-1.5 text-sm font-medium text-danger-700 dark:text-danger-300"
>
<i aria-hidden="true" class="mt-0.5 fa-solid fa-circle-exclamation"> </i>
<span>Select an option.</span>
</p>
</template>
</div>
<div
id="searchable-size-medium-field"
x-data="searchableSelect(Object.assign({}, {}))"
x-on:focusout="onFocusOut($event)"
class="relative group/combo"
>
<div class="flex items-center gap-1 mb-1.5">
<label
id="searchable-size-medium-label"
for="searchable-size-medium"
class="block text-sm font-medium text-dominant-700 dark:text-dominant-200"
>
<span>Medium</span>
</label>
</div>
<div class="relative">
<button
id="searchable-size-medium"
class="block inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 pr-16 w-full text-dominant-900 dark:text-white text-left bg-white dark:bg-dominant-950 rounded-lg cursor-pointer placeholder:text-dominant-600 dark:placeholder:text-dominant-400 focus:inset-ring-primary-500 dark:focus:inset-ring-primary-400 focus:ring-2 focus:ring-primary-500/30 dark:focus:ring-primary-400/30 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:inset-ring-danger-600 dark:aria-invalid:inset-ring-danger-400 aria-invalid:focus:inset-ring-danger-600 dark:aria-invalid:focus:inset-ring-danger-400 aria-invalid:focus:ring-danger-600/30 dark:aria-invalid:focus:ring-danger-400/30 px-3.5 py-2.5 text-sm"
x-ref="trigger"
type="button"
aria-haspopup="listbox"
aria-controls="searchable-size-medium-panel"
aria-expanded="false"
x-bind:aria-invalid="showError ? 'true' : null"
x-bind:aria-required="required ? 'true' : null"
x-bind:disabled="disabled"
x-on:click="onTrigger()"
x-on:keydown.down.prevent="onArrow()"
x-bind:aria-describedby="[showError ? 'searchable-size-medium-error' : null].filter(Boolean).join(' ') || null"
aria-labelledby="searchable-size-medium-label searchable-size-medium-value"
>
<span
id="searchable-size-medium-value"
x-bind:class="hasValue ? '' : 'text-dominant-600 dark:text-dominant-400'"
data-placeholder="Select a category"
x-text="hasValue ? selected[0].text : $el.dataset.placeholder"
class="block truncate"
>Select a category</span
>
</button>
<button
type="button"
aria-label="Clear Medium"
x-bind:hidden="!hasValue || disabled"
x-on:click="clear()"
class="absolute top-1/2 right-9 flex items-center justify-center size-6 text-xs text-dominant-600 dark:text-dominant-300 rounded-full cursor-pointer transition-colors -translate-y-1/2 hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
<i
aria-hidden="true"
class="absolute top-1/2 right-3.5 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-chevron-down"
>
</i>
</div>
<div
id="searchable-size-medium-panel"
class="absolute z-10 mt-1 w-full bg-white dark:bg-dominant-800 rounded-lg border border-dominant-200 dark:border-dominant-700 opacity-0 shadow-lg invisible origin-top scale-95 transition-all duration-150 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:visible group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:scale-100 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:opacity-100"
>
<div class="p-2 border-b border-dominant-200 dark:border-dominant-700">
<div class="relative">
<i
aria-hidden="true"
class="absolute top-1/2 left-3 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-magnifying-glass"
>
</i>
<input
x-ref="search"
x-model="query"
type="text"
role="combobox"
autocomplete="off"
aria-autocomplete="list"
aria-expanded="true"
aria-controls="searchable-size-medium-list"
x-bind:aria-activedescendant="activeId"
aria-label="Search Medium"
placeholder="Search…"
x-on:input="onInput()"
x-on:keydown.down.prevent="move(1)"
x-on:keydown.up.prevent="move(-1)"
x-on:keydown.enter.prevent="onEnter()"
class="block inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 px-3 py-1.5 pl-9 w-full text-dominant-900 dark:text-white text-sm bg-white dark:bg-dominant-950 rounded-lg placeholder:text-dominant-600 dark:placeholder:text-dominant-400 focus:inset-ring-primary-500 dark:focus:inset-ring-primary-400 focus:ring-2 focus:ring-primary-500/30 dark:focus:ring-primary-400/30 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50"
/>
</div>
</div>
<div x-ref="scroller" x-on:scroll="onScroll($event)" class="overflow-y-auto max-h-60">
<ul
id="searchable-size-medium-list"
role="listbox"
aria-labelledby="searchable-size-medium-label"
class="p-1"
>
<template x-for="(option, index) in visible" x-bind:key="option.value">
<li
role="option"
x-bind:id="optionId(index)"
x-bind:aria-selected="String(isSelected(option))"
x-on:click="choose(option)"
x-on:mousemove="active = index"
x-bind:class="index === active ? 'bg-dominant-100 dark:bg-dominant-700' : ''"
class="flex items-center gap-3 px-3 py-2 text-sm text-dominant-900 dark:text-dominant-100 rounded-md cursor-pointer"
>
<span class="flex-1 min-w-0">
<span x-text="option.text" class="block truncate"> </span>
<template x-if="option.description">
<span
x-text="option.description"
class="block truncate text-xs text-dominant-600 dark:text-dominant-200"
>
</span>
</template>
</span>
<template x-if="isSelected(option)">
<i
aria-hidden="true"
class="text-xs text-dominant-900 dark:text-white fa-solid fa-check"
>
</i>
</template>
</li>
</template>
</ul>
<p
x-bind:hidden="!message"
class="flex items-center gap-2 px-3 py-2 text-sm text-dominant-600 dark:text-dominant-300"
>
<i
x-bind:hidden="!loading"
aria-hidden="true"
class="text-xs fa-solid fa-spinner fa-spin"
>
</i>
<span x-text="message"> </span>
<button
id="searchable-size-medium-retry"
type="button"
x-bind:hidden="!error"
x-on:click="retry()"
class="font-semibold rounded underline-offset-2 focus-visible:ring-2 focus-visible:outline-none cursor-pointer text-primary-700 dark:text-primary-300 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 underline hover:text-primary-800 dark:hover:text-primary-200 ml-auto"
>
<span>Try again</span>
</button>
</p>
</div>
<p role="status" x-text="status" class="sr-only"></p>
</div>
<select
id="searchable-size-medium-select"
name="size-medium"
x-ref="select"
tabindex="-1"
aria-hidden="true"
x-on:invalid.prevent="onInvalid($event)"
class="sr-only"
>
<option value="apparel">Apparel</option>
<option value="books">Books</option>
<option value="shoes">Shoes</option>
<template x-if="!multiple">
<option value x-bind:selected="!hasValue"></option>
</template>
<template x-for="item in selected" x-bind:key="item.value">
<option x-bind:value="item.value" selected x-text="item.text"></option>
</template>
</select>
<template x-if="showError">
<p
id="searchable-size-medium-error"
class="flex items-start gap-1.5 mt-1.5 text-sm font-medium text-danger-700 dark:text-danger-300"
>
<i aria-hidden="true" class="mt-0.5 fa-solid fa-circle-exclamation"> </i>
<span>Select an option.</span>
</p>
</template>
</div>
<div
id="searchable-size-large-field"
x-data="searchableSelect(Object.assign({}, {}))"
x-on:focusout="onFocusOut($event)"
class="relative group/combo"
>
<div class="flex items-center gap-1 mb-1.5">
<label
id="searchable-size-large-label"
for="searchable-size-large"
class="block text-sm font-medium text-dominant-700 dark:text-dominant-200"
>
<span>Large</span>
</label>
</div>
<div class="relative">
<button
id="searchable-size-large"
class="block inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 pr-16 w-full text-dominant-900 dark:text-white text-left bg-white dark:bg-dominant-950 rounded-lg cursor-pointer placeholder:text-dominant-600 dark:placeholder:text-dominant-400 focus:inset-ring-primary-500 dark:focus:inset-ring-primary-400 focus:ring-2 focus:ring-primary-500/30 dark:focus:ring-primary-400/30 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:inset-ring-danger-600 dark:aria-invalid:inset-ring-danger-400 aria-invalid:focus:inset-ring-danger-600 dark:aria-invalid:focus:inset-ring-danger-400 aria-invalid:focus:ring-danger-600/30 dark:aria-invalid:focus:ring-danger-400/30 px-4 py-3 text-base"
x-ref="trigger"
type="button"
aria-haspopup="listbox"
aria-controls="searchable-size-large-panel"
aria-expanded="false"
x-bind:aria-invalid="showError ? 'true' : null"
x-bind:aria-required="required ? 'true' : null"
x-bind:disabled="disabled"
x-on:click="onTrigger()"
x-on:keydown.down.prevent="onArrow()"
x-bind:aria-describedby="[showError ? 'searchable-size-large-error' : null].filter(Boolean).join(' ') || null"
aria-labelledby="searchable-size-large-label searchable-size-large-value"
>
<span
id="searchable-size-large-value"
x-bind:class="hasValue ? '' : 'text-dominant-600 dark:text-dominant-400'"
data-placeholder="Select a category"
x-text="hasValue ? selected[0].text : $el.dataset.placeholder"
class="block truncate"
>Select a category</span
>
</button>
<button
type="button"
aria-label="Clear Large"
x-bind:hidden="!hasValue || disabled"
x-on:click="clear()"
class="absolute top-1/2 right-9 flex items-center justify-center size-6 text-xs text-dominant-600 dark:text-dominant-300 rounded-full cursor-pointer transition-colors -translate-y-1/2 hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
<i
aria-hidden="true"
class="absolute top-1/2 right-3.5 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-chevron-down"
>
</i>
</div>
<div
id="searchable-size-large-panel"
class="absolute z-10 mt-1 w-full bg-white dark:bg-dominant-800 rounded-lg border border-dominant-200 dark:border-dominant-700 opacity-0 shadow-lg invisible origin-top scale-95 transition-all duration-150 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:visible group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:scale-100 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:opacity-100"
>
<div class="p-2 border-b border-dominant-200 dark:border-dominant-700">
<div class="relative">
<i
aria-hidden="true"
class="absolute top-1/2 left-3 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-magnifying-glass"
>
</i>
<input
x-ref="search"
x-model="query"
type="text"
role="combobox"
autocomplete="off"
aria-autocomplete="list"
aria-expanded="true"
aria-controls="searchable-size-large-list"
x-bind:aria-activedescendant="activeId"
aria-label="Search Large"
placeholder="Search…"
x-on:input="onInput()"
x-on:keydown.down.prevent="move(1)"
x-on:keydown.up.prevent="move(-1)"
x-on:keydown.enter.prevent="onEnter()"
class="block inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 px-3 py-1.5 pl-9 w-full text-dominant-900 dark:text-white text-sm bg-white dark:bg-dominant-950 rounded-lg placeholder:text-dominant-600 dark:placeholder:text-dominant-400 focus:inset-ring-primary-500 dark:focus:inset-ring-primary-400 focus:ring-2 focus:ring-primary-500/30 dark:focus:ring-primary-400/30 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50"
/>
</div>
</div>
<div x-ref="scroller" x-on:scroll="onScroll($event)" class="overflow-y-auto max-h-60">
<ul
id="searchable-size-large-list"
role="listbox"
aria-labelledby="searchable-size-large-label"
class="p-1"
>
<template x-for="(option, index) in visible" x-bind:key="option.value">
<li
role="option"
x-bind:id="optionId(index)"
x-bind:aria-selected="String(isSelected(option))"
x-on:click="choose(option)"
x-on:mousemove="active = index"
x-bind:class="index === active ? 'bg-dominant-100 dark:bg-dominant-700' : ''"
class="flex items-center gap-3 px-3 py-2 text-sm text-dominant-900 dark:text-dominant-100 rounded-md cursor-pointer"
>
<span class="flex-1 min-w-0">
<span x-text="option.text" class="block truncate"> </span>
<template x-if="option.description">
<span
x-text="option.description"
class="block truncate text-xs text-dominant-600 dark:text-dominant-200"
>
</span>
</template>
</span>
<template x-if="isSelected(option)">
<i
aria-hidden="true"
class="text-xs text-dominant-900 dark:text-white fa-solid fa-check"
>
</i>
</template>
</li>
</template>
</ul>
<p
x-bind:hidden="!message"
class="flex items-center gap-2 px-3 py-2 text-sm text-dominant-600 dark:text-dominant-300"
>
<i
x-bind:hidden="!loading"
aria-hidden="true"
class="text-xs fa-solid fa-spinner fa-spin"
>
</i>
<span x-text="message"> </span>
<button
id="searchable-size-large-retry"
type="button"
x-bind:hidden="!error"
x-on:click="retry()"
class="font-semibold rounded underline-offset-2 focus-visible:ring-2 focus-visible:outline-none cursor-pointer text-primary-700 dark:text-primary-300 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 underline hover:text-primary-800 dark:hover:text-primary-200 ml-auto"
>
<span>Try again</span>
</button>
</p>
</div>
<p role="status" x-text="status" class="sr-only"></p>
</div>
<select
id="searchable-size-large-select"
name="size-large"
x-ref="select"
tabindex="-1"
aria-hidden="true"
x-on:invalid.prevent="onInvalid($event)"
class="sr-only"
>
<option value="apparel">Apparel</option>
<option value="books">Books</option>
<option value="shoes">Shoes</option>
<template x-if="!multiple">
<option value x-bind:selected="!hasValue"></option>
</template>
<template x-for="item in selected" x-bind:key="item.value">
<option x-bind:value="item.value" selected x-text="item.text"></option>
</template>
</select>
<template x-if="showError">
<p
id="searchable-size-large-error"
class="flex items-start gap-1.5 mt-1.5 text-sm font-medium text-danger-700 dark:text-danger-300"
>
<i aria-hidden="true" class="mt-0.5 fa-solid fa-circle-exclamation"> </i>
<span>Select an option.</span>
</p>
</template>
</div>
</div>
<div class="grid grid-cols-1 gap-5 sm:grid-cols-3">
<div
id="searchable-size-multiple-small-field"
x-data='searchableSelect(Object.assign({"multiple":true}, {}))'
x-on:focusout="onFocusOut($event)"
class="relative group/combo"
>
<div class="flex items-center gap-1 mb-1.5">
<label
id="searchable-size-multiple-small-label"
for="searchable-size-multiple-small"
class="block text-sm font-medium text-dominant-700 dark:text-dominant-200"
>
<span>Small, multiple</span>
</label>
</div>
<div class="relative">
<div
class="h-8 flex flex-nowrap items-center gap-1.5 overflow-hidden inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 pr-16 pl-2.5 w-full bg-white dark:bg-dominant-950 rounded-lg focus-within:inset-ring-primary-500 dark:focus-within:inset-ring-primary-400 focus-within:ring-2 focus-within:ring-primary-500/30 dark:focus-within:ring-primary-400/30 has-[button[aria-invalid=true]]:inset-ring-danger-600 dark:has-[button[aria-invalid=true]]:inset-ring-danger-400 has-[button[aria-invalid=true]]:focus-within:inset-ring-danger-600 dark:has-[button[aria-invalid=true]]:focus-within:inset-ring-danger-400 has-[button[aria-invalid=true]]:focus-within:ring-danger-600/30 dark:has-[button[aria-invalid=true]]:focus-within:ring-danger-400/30"
>
<template x-for="item in chips" x-bind:key="item.value">
<span
class="relative z-1 inline-flex shrink items-center gap-1 py-0.5 pr-1 pl-2 min-w-0 text-sm font-medium text-dominant-900 dark:text-dominant-100 bg-dominant-200 dark:bg-dominant-700 rounded-md"
>
<span x-text="item.text" class="truncate"> </span>
<button
type="button"
x-bind:aria-label="'Remove ' + item.text"
x-on:click="remove(item)"
class="flex shrink-0 items-center justify-center size-5 text-xs rounded cursor-pointer transition-colors hover:bg-dominant-300 dark:hover:bg-dominant-600 focus-visible:ring-2 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
</span>
</template>
<template x-if="hiddenCount">
<span
aria-hidden="true"
x-text="'+' + hiddenCount"
class="inline-flex shrink-0 items-center px-2 py-0.5 text-sm font-medium text-dominant-900 dark:text-dominant-100 bg-dominant-200 dark:bg-dominant-700 rounded-md"
>
</span>
</template>
<button
id="searchable-size-multiple-small"
class="flex-1 px-1 py-1 min-w-0 truncate text-left text-sm text-dominant-600 dark:text-dominant-400 bg-transparent rounded cursor-pointer focus:outline-none after:absolute after:inset-0 after:content-['']"
x-ref="trigger"
type="button"
aria-haspopup="listbox"
aria-controls="searchable-size-multiple-small-panel"
aria-expanded="false"
x-bind:aria-invalid="showError ? 'true' : null"
x-bind:aria-required="required ? 'true' : null"
x-bind:disabled="disabled"
x-on:click="onTrigger()"
x-on:keydown.down.prevent="onArrow()"
x-bind:aria-describedby="[showError ? 'searchable-size-multiple-small-error' : null].filter(Boolean).join(' ') || null"
aria-labelledby="searchable-size-multiple-small-label"
>
<span
data-placeholder="Add a category…"
x-bind:class="{ 'sr-only': hasValue }"
x-text="hasValue ? summary : $el.dataset.placeholder"
>Add a category…</span
>
</button>
<button
type="button"
aria-label="Clear all Small, multiple"
title="Clear all"
x-bind:hidden="!hasValue"
x-on:click="clear()"
class="absolute top-1/2 right-9 flex items-center justify-center size-6 text-xs text-dominant-600 dark:text-dominant-300 rounded-full cursor-pointer transition-colors -translate-y-1/2 hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
<i
aria-hidden="true"
class="absolute top-1/2 right-3.5 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-chevron-down"
>
</i>
</div>
</div>
<div
id="searchable-size-multiple-small-panel"
class="absolute z-10 mt-1 w-full bg-white dark:bg-dominant-800 rounded-lg border border-dominant-200 dark:border-dominant-700 opacity-0 shadow-lg invisible origin-top scale-95 transition-all duration-150 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:visible group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:scale-100 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:opacity-100"
>
<div class="p-2 border-b border-dominant-200 dark:border-dominant-700">
<div class="relative">
<i
aria-hidden="true"
class="absolute top-1/2 left-3 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-magnifying-glass"
>
</i>
<input
x-ref="search"
x-model="query"
type="text"
role="combobox"
autocomplete="off"
aria-autocomplete="list"
aria-expanded="true"
aria-controls="searchable-size-multiple-small-list"
x-bind:aria-activedescendant="activeId"
aria-label="Search Small, multiple"
placeholder="Search…"
x-on:input="onInput()"
x-on:keydown.down.prevent="move(1)"
x-on:keydown.up.prevent="move(-1)"
x-on:keydown.enter.prevent="onEnter()"
class="block inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 px-3 py-1.5 pl-9 w-full text-dominant-900 dark:text-white text-sm bg-white dark:bg-dominant-950 rounded-lg placeholder:text-dominant-600 dark:placeholder:text-dominant-400 focus:inset-ring-primary-500 dark:focus:inset-ring-primary-400 focus:ring-2 focus:ring-primary-500/30 dark:focus:ring-primary-400/30 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50"
/>
</div>
</div>
<div x-ref="scroller" x-on:scroll="onScroll($event)" class="overflow-y-auto max-h-60">
<ul
id="searchable-size-multiple-small-list"
role="listbox"
aria-labelledby="searchable-size-multiple-small-label"
aria-multiselectable="true"
class="p-1"
>
<template x-for="(option, index) in visible" x-bind:key="option.value">
<li
role="option"
x-bind:id="optionId(index)"
x-bind:aria-selected="String(isSelected(option))"
x-on:click="choose(option)"
x-on:mousemove="active = index"
x-bind:class="index === active ? 'bg-dominant-100 dark:bg-dominant-700' : ''"
class="flex items-center gap-3 px-3 py-2 text-sm text-dominant-900 dark:text-dominant-100 rounded-md cursor-pointer"
>
<span class="flex-1 min-w-0">
<span x-text="option.text" class="block truncate"> </span>
<template x-if="option.description">
<span
x-text="option.description"
class="block truncate text-xs text-dominant-600 dark:text-dominant-200"
>
</span>
</template>
</span>
<template x-if="isSelected(option)">
<i
aria-hidden="true"
class="text-xs text-dominant-900 dark:text-white fa-solid fa-check"
>
</i>
</template>
</li>
</template>
</ul>
<p
x-bind:hidden="!message"
class="flex items-center gap-2 px-3 py-2 text-sm text-dominant-600 dark:text-dominant-300"
>
<i
x-bind:hidden="!loading"
aria-hidden="true"
class="text-xs fa-solid fa-spinner fa-spin"
>
</i>
<span x-text="message"> </span>
<button
id="searchable-size-multiple-small-retry"
type="button"
x-bind:hidden="!error"
x-on:click="retry()"
class="font-semibold rounded underline-offset-2 focus-visible:ring-2 focus-visible:outline-none cursor-pointer text-primary-700 dark:text-primary-300 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 underline hover:text-primary-800 dark:hover:text-primary-200 ml-auto"
>
<span>Try again</span>
</button>
</p>
</div>
<p role="status" x-text="status" class="sr-only"></p>
</div>
<select
id="searchable-size-multiple-small-select"
name="sizes-small[]"
x-ref="select"
tabindex="-1"
aria-hidden="true"
multiple="true"
x-on:invalid.prevent="onInvalid($event)"
class="sr-only"
>
<option value="apparel">Apparel</option>
<option value="books">Books</option>
<option value="shoes">Shoes</option>
<template x-if="!multiple">
<option value x-bind:selected="!hasValue"></option>
</template>
<template x-for="item in selected" x-bind:key="item.value">
<option x-bind:value="item.value" selected x-text="item.text"></option>
</template>
</select>
<template x-if="showError">
<p
id="searchable-size-multiple-small-error"
class="flex items-start gap-1.5 mt-1.5 text-sm font-medium text-danger-700 dark:text-danger-300"
>
<i aria-hidden="true" class="mt-0.5 fa-solid fa-circle-exclamation"> </i>
<span>Select an option.</span>
</p>
</template>
</div>
<div
id="searchable-size-multiple-medium-field"
x-data='searchableSelect(Object.assign({"multiple":true}, {}))'
x-on:focusout="onFocusOut($event)"
class="relative group/combo"
>
<div class="flex items-center gap-1 mb-1.5">
<label
id="searchable-size-multiple-medium-label"
for="searchable-size-multiple-medium"
class="block text-sm font-medium text-dominant-700 dark:text-dominant-200"
>
<span>Medium, multiple</span>
</label>
</div>
<div class="relative">
<div
class="h-10 flex flex-nowrap items-center gap-1.5 overflow-hidden inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 pr-16 pl-2.5 w-full bg-white dark:bg-dominant-950 rounded-lg focus-within:inset-ring-primary-500 dark:focus-within:inset-ring-primary-400 focus-within:ring-2 focus-within:ring-primary-500/30 dark:focus-within:ring-primary-400/30 has-[button[aria-invalid=true]]:inset-ring-danger-600 dark:has-[button[aria-invalid=true]]:inset-ring-danger-400 has-[button[aria-invalid=true]]:focus-within:inset-ring-danger-600 dark:has-[button[aria-invalid=true]]:focus-within:inset-ring-danger-400 has-[button[aria-invalid=true]]:focus-within:ring-danger-600/30 dark:has-[button[aria-invalid=true]]:focus-within:ring-danger-400/30"
>
<template x-for="item in chips" x-bind:key="item.value">
<span
class="relative z-1 inline-flex shrink items-center gap-1 py-0.5 pr-1 pl-2 min-w-0 text-sm font-medium text-dominant-900 dark:text-dominant-100 bg-dominant-200 dark:bg-dominant-700 rounded-md"
>
<span x-text="item.text" class="truncate"> </span>
<button
type="button"
x-bind:aria-label="'Remove ' + item.text"
x-on:click="remove(item)"
class="flex shrink-0 items-center justify-center size-5 text-xs rounded cursor-pointer transition-colors hover:bg-dominant-300 dark:hover:bg-dominant-600 focus-visible:ring-2 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
</span>
</template>
<template x-if="hiddenCount">
<span
aria-hidden="true"
x-text="'+' + hiddenCount"
class="inline-flex shrink-0 items-center px-2 py-0.5 text-sm font-medium text-dominant-900 dark:text-dominant-100 bg-dominant-200 dark:bg-dominant-700 rounded-md"
>
</span>
</template>
<button
id="searchable-size-multiple-medium"
class="flex-1 px-1 py-1 min-w-0 truncate text-left text-sm text-dominant-600 dark:text-dominant-400 bg-transparent rounded cursor-pointer focus:outline-none after:absolute after:inset-0 after:content-['']"
x-ref="trigger"
type="button"
aria-haspopup="listbox"
aria-controls="searchable-size-multiple-medium-panel"
aria-expanded="false"
x-bind:aria-invalid="showError ? 'true' : null"
x-bind:aria-required="required ? 'true' : null"
x-bind:disabled="disabled"
x-on:click="onTrigger()"
x-on:keydown.down.prevent="onArrow()"
x-bind:aria-describedby="[showError ? 'searchable-size-multiple-medium-error' : null].filter(Boolean).join(' ') || null"
aria-labelledby="searchable-size-multiple-medium-label"
>
<span
data-placeholder="Add a category…"
x-bind:class="{ 'sr-only': hasValue }"
x-text="hasValue ? summary : $el.dataset.placeholder"
>Add a category…</span
>
</button>
<button
type="button"
aria-label="Clear all Medium, multiple"
title="Clear all"
x-bind:hidden="!hasValue"
x-on:click="clear()"
class="absolute top-1/2 right-9 flex items-center justify-center size-6 text-xs text-dominant-600 dark:text-dominant-300 rounded-full cursor-pointer transition-colors -translate-y-1/2 hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
<i
aria-hidden="true"
class="absolute top-1/2 right-3.5 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-chevron-down"
>
</i>
</div>
</div>
<div
id="searchable-size-multiple-medium-panel"
class="absolute z-10 mt-1 w-full bg-white dark:bg-dominant-800 rounded-lg border border-dominant-200 dark:border-dominant-700 opacity-0 shadow-lg invisible origin-top scale-95 transition-all duration-150 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:visible group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:scale-100 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:opacity-100"
>
<div class="p-2 border-b border-dominant-200 dark:border-dominant-700">
<div class="relative">
<i
aria-hidden="true"
class="absolute top-1/2 left-3 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-magnifying-glass"
>
</i>
<input
x-ref="search"
x-model="query"
type="text"
role="combobox"
autocomplete="off"
aria-autocomplete="list"
aria-expanded="true"
aria-controls="searchable-size-multiple-medium-list"
x-bind:aria-activedescendant="activeId"
aria-label="Search Medium, multiple"
placeholder="Search…"
x-on:input="onInput()"
x-on:keydown.down.prevent="move(1)"
x-on:keydown.up.prevent="move(-1)"
x-on:keydown.enter.prevent="onEnter()"
class="block inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 px-3 py-1.5 pl-9 w-full text-dominant-900 dark:text-white text-sm bg-white dark:bg-dominant-950 rounded-lg placeholder:text-dominant-600 dark:placeholder:text-dominant-400 focus:inset-ring-primary-500 dark:focus:inset-ring-primary-400 focus:ring-2 focus:ring-primary-500/30 dark:focus:ring-primary-400/30 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50"
/>
</div>
</div>
<div x-ref="scroller" x-on:scroll="onScroll($event)" class="overflow-y-auto max-h-60">
<ul
id="searchable-size-multiple-medium-list"
role="listbox"
aria-labelledby="searchable-size-multiple-medium-label"
aria-multiselectable="true"
class="p-1"
>
<template x-for="(option, index) in visible" x-bind:key="option.value">
<li
role="option"
x-bind:id="optionId(index)"
x-bind:aria-selected="String(isSelected(option))"
x-on:click="choose(option)"
x-on:mousemove="active = index"
x-bind:class="index === active ? 'bg-dominant-100 dark:bg-dominant-700' : ''"
class="flex items-center gap-3 px-3 py-2 text-sm text-dominant-900 dark:text-dominant-100 rounded-md cursor-pointer"
>
<span class="flex-1 min-w-0">
<span x-text="option.text" class="block truncate"> </span>
<template x-if="option.description">
<span
x-text="option.description"
class="block truncate text-xs text-dominant-600 dark:text-dominant-200"
>
</span>
</template>
</span>
<template x-if="isSelected(option)">
<i
aria-hidden="true"
class="text-xs text-dominant-900 dark:text-white fa-solid fa-check"
>
</i>
</template>
</li>
</template>
</ul>
<p
x-bind:hidden="!message"
class="flex items-center gap-2 px-3 py-2 text-sm text-dominant-600 dark:text-dominant-300"
>
<i
x-bind:hidden="!loading"
aria-hidden="true"
class="text-xs fa-solid fa-spinner fa-spin"
>
</i>
<span x-text="message"> </span>
<button
id="searchable-size-multiple-medium-retry"
type="button"
x-bind:hidden="!error"
x-on:click="retry()"
class="font-semibold rounded underline-offset-2 focus-visible:ring-2 focus-visible:outline-none cursor-pointer text-primary-700 dark:text-primary-300 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 underline hover:text-primary-800 dark:hover:text-primary-200 ml-auto"
>
<span>Try again</span>
</button>
</p>
</div>
<p role="status" x-text="status" class="sr-only"></p>
</div>
<select
id="searchable-size-multiple-medium-select"
name="sizes-medium[]"
x-ref="select"
tabindex="-1"
aria-hidden="true"
multiple="true"
x-on:invalid.prevent="onInvalid($event)"
class="sr-only"
>
<option value="apparel">Apparel</option>
<option value="books">Books</option>
<option value="shoes">Shoes</option>
<template x-if="!multiple">
<option value x-bind:selected="!hasValue"></option>
</template>
<template x-for="item in selected" x-bind:key="item.value">
<option x-bind:value="item.value" selected x-text="item.text"></option>
</template>
</select>
<template x-if="showError">
<p
id="searchable-size-multiple-medium-error"
class="flex items-start gap-1.5 mt-1.5 text-sm font-medium text-danger-700 dark:text-danger-300"
>
<i aria-hidden="true" class="mt-0.5 fa-solid fa-circle-exclamation"> </i>
<span>Select an option.</span>
</p>
</template>
</div>
<div
id="searchable-size-multiple-large-field"
x-data='searchableSelect(Object.assign({"multiple":true}, {}))'
x-on:focusout="onFocusOut($event)"
class="relative group/combo"
>
<div class="flex items-center gap-1 mb-1.5">
<label
id="searchable-size-multiple-large-label"
for="searchable-size-multiple-large"
class="block text-sm font-medium text-dominant-700 dark:text-dominant-200"
>
<span>Large, multiple</span>
</label>
</div>
<div class="relative">
<div
class="h-12 flex flex-nowrap items-center gap-1.5 overflow-hidden inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 pr-16 pl-2.5 w-full bg-white dark:bg-dominant-950 rounded-lg focus-within:inset-ring-primary-500 dark:focus-within:inset-ring-primary-400 focus-within:ring-2 focus-within:ring-primary-500/30 dark:focus-within:ring-primary-400/30 has-[button[aria-invalid=true]]:inset-ring-danger-600 dark:has-[button[aria-invalid=true]]:inset-ring-danger-400 has-[button[aria-invalid=true]]:focus-within:inset-ring-danger-600 dark:has-[button[aria-invalid=true]]:focus-within:inset-ring-danger-400 has-[button[aria-invalid=true]]:focus-within:ring-danger-600/30 dark:has-[button[aria-invalid=true]]:focus-within:ring-danger-400/30"
>
<template x-for="item in chips" x-bind:key="item.value">
<span
class="relative z-1 inline-flex shrink items-center gap-1 py-0.5 pr-1 pl-2 min-w-0 text-sm font-medium text-dominant-900 dark:text-dominant-100 bg-dominant-200 dark:bg-dominant-700 rounded-md"
>
<span x-text="item.text" class="truncate"> </span>
<button
type="button"
x-bind:aria-label="'Remove ' + item.text"
x-on:click="remove(item)"
class="flex shrink-0 items-center justify-center size-5 text-xs rounded cursor-pointer transition-colors hover:bg-dominant-300 dark:hover:bg-dominant-600 focus-visible:ring-2 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
</span>
</template>
<template x-if="hiddenCount">
<span
aria-hidden="true"
x-text="'+' + hiddenCount"
class="inline-flex shrink-0 items-center px-2 py-0.5 text-sm font-medium text-dominant-900 dark:text-dominant-100 bg-dominant-200 dark:bg-dominant-700 rounded-md"
>
</span>
</template>
<button
id="searchable-size-multiple-large"
class="flex-1 px-1 py-1 min-w-0 truncate text-left text-sm text-dominant-600 dark:text-dominant-400 bg-transparent rounded cursor-pointer focus:outline-none after:absolute after:inset-0 after:content-['']"
x-ref="trigger"
type="button"
aria-haspopup="listbox"
aria-controls="searchable-size-multiple-large-panel"
aria-expanded="false"
x-bind:aria-invalid="showError ? 'true' : null"
x-bind:aria-required="required ? 'true' : null"
x-bind:disabled="disabled"
x-on:click="onTrigger()"
x-on:keydown.down.prevent="onArrow()"
x-bind:aria-describedby="[showError ? 'searchable-size-multiple-large-error' : null].filter(Boolean).join(' ') || null"
aria-labelledby="searchable-size-multiple-large-label"
>
<span
data-placeholder="Add a category…"
x-bind:class="{ 'sr-only': hasValue }"
x-text="hasValue ? summary : $el.dataset.placeholder"
>Add a category…</span
>
</button>
<button
type="button"
aria-label="Clear all Large, multiple"
title="Clear all"
x-bind:hidden="!hasValue"
x-on:click="clear()"
class="absolute top-1/2 right-9 flex items-center justify-center size-6 text-xs text-dominant-600 dark:text-dominant-300 rounded-full cursor-pointer transition-colors -translate-y-1/2 hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
<i
aria-hidden="true"
class="absolute top-1/2 right-3.5 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-chevron-down"
>
</i>
</div>
</div>
<div
id="searchable-size-multiple-large-panel"
class="absolute z-10 mt-1 w-full bg-white dark:bg-dominant-800 rounded-lg border border-dominant-200 dark:border-dominant-700 opacity-0 shadow-lg invisible origin-top scale-95 transition-all duration-150 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:visible group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:scale-100 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:opacity-100"
>
<div class="p-2 border-b border-dominant-200 dark:border-dominant-700">
<div class="relative">
<i
aria-hidden="true"
class="absolute top-1/2 left-3 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-magnifying-glass"
>
</i>
<input
x-ref="search"
x-model="query"
type="text"
role="combobox"
autocomplete="off"
aria-autocomplete="list"
aria-expanded="true"
aria-controls="searchable-size-multiple-large-list"
x-bind:aria-activedescendant="activeId"
aria-label="Search Large, multiple"
placeholder="Search…"
x-on:input="onInput()"
x-on:keydown.down.prevent="move(1)"
x-on:keydown.up.prevent="move(-1)"
x-on:keydown.enter.prevent="onEnter()"
class="block inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 px-3 py-1.5 pl-9 w-full text-dominant-900 dark:text-white text-sm bg-white dark:bg-dominant-950 rounded-lg placeholder:text-dominant-600 dark:placeholder:text-dominant-400 focus:inset-ring-primary-500 dark:focus:inset-ring-primary-400 focus:ring-2 focus:ring-primary-500/30 dark:focus:ring-primary-400/30 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50"
/>
</div>
</div>
<div x-ref="scroller" x-on:scroll="onScroll($event)" class="overflow-y-auto max-h-60">
<ul
id="searchable-size-multiple-large-list"
role="listbox"
aria-labelledby="searchable-size-multiple-large-label"
aria-multiselectable="true"
class="p-1"
>
<template x-for="(option, index) in visible" x-bind:key="option.value">
<li
role="option"
x-bind:id="optionId(index)"
x-bind:aria-selected="String(isSelected(option))"
x-on:click="choose(option)"
x-on:mousemove="active = index"
x-bind:class="index === active ? 'bg-dominant-100 dark:bg-dominant-700' : ''"
class="flex items-center gap-3 px-3 py-2 text-sm text-dominant-900 dark:text-dominant-100 rounded-md cursor-pointer"
>
<span class="flex-1 min-w-0">
<span x-text="option.text" class="block truncate"> </span>
<template x-if="option.description">
<span
x-text="option.description"
class="block truncate text-xs text-dominant-600 dark:text-dominant-200"
>
</span>
</template>
</span>
<template x-if="isSelected(option)">
<i
aria-hidden="true"
class="text-xs text-dominant-900 dark:text-white fa-solid fa-check"
>
</i>
</template>
</li>
</template>
</ul>
<p
x-bind:hidden="!message"
class="flex items-center gap-2 px-3 py-2 text-sm text-dominant-600 dark:text-dominant-300"
>
<i
x-bind:hidden="!loading"
aria-hidden="true"
class="text-xs fa-solid fa-spinner fa-spin"
>
</i>
<span x-text="message"> </span>
<button
id="searchable-size-multiple-large-retry"
type="button"
x-bind:hidden="!error"
x-on:click="retry()"
class="font-semibold rounded underline-offset-2 focus-visible:ring-2 focus-visible:outline-none cursor-pointer text-primary-700 dark:text-primary-300 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 underline hover:text-primary-800 dark:hover:text-primary-200 ml-auto"
>
<span>Try again</span>
</button>
</p>
</div>
<p role="status" x-text="status" class="sr-only"></p>
</div>
<select
id="searchable-size-multiple-large-select"
name="sizes-large[]"
x-ref="select"
tabindex="-1"
aria-hidden="true"
multiple="true"
x-on:invalid.prevent="onInvalid($event)"
class="sr-only"
>
<option value="apparel">Apparel</option>
<option value="books">Books</option>
<option value="shoes">Shoes</option>
<template x-if="!multiple">
<option value x-bind:selected="!hasValue"></option>
</template>
<template x-for="item in selected" x-bind:key="item.value">
<option x-bind:value="item.value" selected x-text="item.text"></option>
</template>
</select>
<template x-if="showError">
<p
id="searchable-size-multiple-large-error"
class="flex items-start gap-1.5 mt-1.5 text-sm font-medium text-danger-700 dark:text-danger-300"
>
<i aria-hidden="true" class="mt-0.5 fa-solid fa-circle-exclamation"> </i>
<span>Select an option.</span>
</p>
</template>
</div>
</div>
Remote data
Give the component a url that follows the Starkit contract and it needs nothing else but map, which says what an item is. It sends GET url?page=&limit=&search=&filters[field]=&sorts[field]= with JSON headers (every parameter is optional; the first request has no page) and reads { data, links: { next } }. The first page loads when the panel opens, and the next page whenever the user scrolls near the end of the list. Typing restarts from page 1 after a short pause. sorts, filters and limit are fixed values of the field: these fields send sorts[name]=asc, and the server answers 10 categories per page. The categories come from a live endpoint, so the page needs a network connection.
Select an option.
Select an option.
<div
id="searchable-category-field"
x-data='searchableSelect(Object.assign({"url":"https://starkit-template.netlify.app/api/starkit-contract/categories","limit":20,"delay":400,"sorts":{"name":"asc"}}, { map: (category) => ({ value: category.id, text: category.name, description: category.description }) }))'
x-on:focusout="onFocusOut($event)"
class="relative group/combo"
>
<div class="flex items-center gap-1 mb-1.5">
<label
id="searchable-category-label"
for="searchable-category"
class="block text-sm font-medium text-dominant-700 dark:text-dominant-200"
>
<span>Category</span>
<span aria-hidden="true" class="text-danger-700 dark:text-danger-300">*</span>
</label>
<button
id="searchable-category-hint-button"
type="button"
aria-controls="searchable-category-hint"
aria-expanded="false"
aria-haspopup="true"
aria-label="Hint for Category"
class="flex shrink-0 items-center justify-center size-6 text-dominant-600 dark:text-dominant-300 rounded-full cursor-pointer transition-colors peer hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-circle-question"> </i>
</button>
<div
id="searchable-category-hint"
class="absolute top-7 left-0 z-10 p-3 w-full max-w-xs text-sm text-dominant-700 dark:text-dominant-200 bg-white dark:bg-dominant-800 opacity-0 rounded-lg border border-dominant-200 dark:border-dominant-700 shadow-lg invisible scale-95 transition-all duration-150 origin-top-left peer-aria-expanded:visible peer-aria-expanded:scale-100 peer-aria-expanded:opacity-100"
>
<span>Choose the category this item belongs to. Type to search by name.</span>
</div>
</div>
<div class="relative">
<button
id="searchable-category"
class="block inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 pr-16 w-full text-dominant-900 dark:text-white text-left bg-white dark:bg-dominant-950 rounded-lg cursor-pointer placeholder:text-dominant-600 dark:placeholder:text-dominant-400 focus:inset-ring-primary-500 dark:focus:inset-ring-primary-400 focus:ring-2 focus:ring-primary-500/30 dark:focus:ring-primary-400/30 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:inset-ring-danger-600 dark:aria-invalid:inset-ring-danger-400 aria-invalid:focus:inset-ring-danger-600 dark:aria-invalid:focus:inset-ring-danger-400 aria-invalid:focus:ring-danger-600/30 dark:aria-invalid:focus:ring-danger-400/30 px-3.5 py-2.5 text-sm"
x-ref="trigger"
type="button"
aria-haspopup="listbox"
aria-controls="searchable-category-panel"
aria-expanded="false"
x-bind:aria-invalid="showError ? 'true' : null"
x-bind:aria-required="required ? 'true' : null"
x-bind:disabled="disabled"
x-on:click="onTrigger()"
x-on:keydown.down.prevent="onArrow()"
x-bind:aria-describedby="['searchable-category-hint', showError ? 'searchable-category-error' : null].filter(Boolean).join(' ') || null"
aria-labelledby="searchable-category-label searchable-category-value"
>
<span
id="searchable-category-value"
x-bind:class="hasValue ? '' : 'text-dominant-600 dark:text-dominant-400'"
data-placeholder="Select a category"
x-text="hasValue ? selected[0].text : $el.dataset.placeholder"
class="block truncate"
>Select a category</span
>
</button>
<button
type="button"
aria-label="Clear Category"
x-bind:hidden="!hasValue || disabled"
x-on:click="clear()"
class="absolute top-1/2 right-9 flex items-center justify-center size-6 text-xs text-dominant-600 dark:text-dominant-300 rounded-full cursor-pointer transition-colors -translate-y-1/2 hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
<i
aria-hidden="true"
class="absolute top-1/2 right-3.5 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-chevron-down"
>
</i>
</div>
<div
id="searchable-category-panel"
class="absolute z-10 mt-1 w-full bg-white dark:bg-dominant-800 rounded-lg border border-dominant-200 dark:border-dominant-700 opacity-0 shadow-lg invisible origin-top scale-95 transition-all duration-150 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:visible group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:scale-100 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:opacity-100"
>
<div class="p-2 border-b border-dominant-200 dark:border-dominant-700">
<div class="relative">
<i
aria-hidden="true"
class="absolute top-1/2 left-3 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-magnifying-glass"
>
</i>
<input
x-ref="search"
x-model="query"
type="text"
role="combobox"
autocomplete="off"
aria-autocomplete="list"
aria-expanded="true"
aria-controls="searchable-category-list"
x-bind:aria-activedescendant="activeId"
aria-label="Search Category"
placeholder="Search…"
x-on:input="onInput()"
x-on:keydown.down.prevent="move(1)"
x-on:keydown.up.prevent="move(-1)"
x-on:keydown.enter.prevent="onEnter()"
class="block inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 px-3 py-1.5 pl-9 w-full text-dominant-900 dark:text-white text-sm bg-white dark:bg-dominant-950 rounded-lg placeholder:text-dominant-600 dark:placeholder:text-dominant-400 focus:inset-ring-primary-500 dark:focus:inset-ring-primary-400 focus:ring-2 focus:ring-primary-500/30 dark:focus:ring-primary-400/30 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50"
/>
</div>
</div>
<div x-ref="scroller" x-on:scroll="onScroll($event)" class="overflow-y-auto max-h-60">
<ul
id="searchable-category-list"
role="listbox"
aria-labelledby="searchable-category-label"
class="p-1"
>
<template x-for="(option, index) in visible" x-bind:key="option.value">
<li
role="option"
x-bind:id="optionId(index)"
x-bind:aria-selected="String(isSelected(option))"
x-on:click="choose(option)"
x-on:mousemove="active = index"
x-bind:class="index === active ? 'bg-dominant-100 dark:bg-dominant-700' : ''"
class="flex items-center gap-3 px-3 py-2 text-sm text-dominant-900 dark:text-dominant-100 rounded-md cursor-pointer"
>
<span class="flex-1 min-w-0">
<span x-text="option.text" class="block truncate"> </span>
<template x-if="option.description">
<span
x-text="option.description"
class="block truncate text-xs text-dominant-600 dark:text-dominant-200"
>
</span>
</template>
</span>
<template x-if="isSelected(option)">
<i
aria-hidden="true"
class="text-xs text-dominant-900 dark:text-white fa-solid fa-check"
>
</i>
</template>
</li>
</template>
</ul>
<p
x-bind:hidden="!message"
class="flex items-center gap-2 px-3 py-2 text-sm text-dominant-600 dark:text-dominant-300"
>
<i x-bind:hidden="!loading" aria-hidden="true" class="text-xs fa-solid fa-spinner fa-spin">
</i>
<span x-text="message"> </span>
<button
id="searchable-category-retry"
type="button"
x-bind:hidden="!error"
x-on:click="retry()"
class="font-semibold rounded underline-offset-2 focus-visible:ring-2 focus-visible:outline-none cursor-pointer text-primary-700 dark:text-primary-300 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 underline hover:text-primary-800 dark:hover:text-primary-200 ml-auto"
>
<span>Try again</span>
</button>
</p>
</div>
<p role="status" x-text="status" class="sr-only"></p>
</div>
<select
id="searchable-category-select"
name="category"
x-ref="select"
tabindex="-1"
aria-hidden="true"
required="true"
x-on:invalid.prevent="onInvalid($event)"
class="sr-only"
>
<template x-if="!multiple">
<option value x-bind:selected="!hasValue"></option>
</template>
<template x-for="item in selected" x-bind:key="item.value">
<option x-bind:value="item.value" selected x-text="item.text"></option>
</template>
</select>
<template x-if="showError">
<p
id="searchable-category-error"
class="flex items-start gap-1.5 mt-1.5 text-sm font-medium text-danger-700 dark:text-danger-300"
>
<i aria-hidden="true" class="mt-0.5 fa-solid fa-circle-exclamation"> </i>
<span>Select an option.</span>
</p>
</template>
</div>
<div
id="searchable-categories-field"
x-data='searchableSelect(Object.assign({"url":"https://starkit-template.netlify.app/api/starkit-contract/categories","maxChips":3,"multiple":true,"sorts":{"name":"asc"}}, { map: (category) => ({ value: category.id, text: category.name, description: category.description }) }))'
x-on:focusout="onFocusOut($event)"
class="relative group/combo"
>
<div class="flex items-center gap-1 mb-1.5">
<label
id="searchable-categories-label"
for="searchable-categories"
class="block text-sm font-medium text-dominant-700 dark:text-dominant-200"
>
<span>Categories</span>
<span aria-hidden="true" class="text-danger-700 dark:text-danger-300">*</span>
</label>
<button
id="searchable-categories-hint-button"
type="button"
aria-controls="searchable-categories-hint"
aria-expanded="false"
aria-haspopup="true"
aria-label="Hint for Categories"
class="flex shrink-0 items-center justify-center size-6 text-dominant-600 dark:text-dominant-300 rounded-full cursor-pointer transition-colors peer hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-circle-question"> </i>
</button>
<div
id="searchable-categories-hint"
class="absolute top-7 left-0 z-10 p-3 w-full max-w-xs text-sm text-dominant-700 dark:text-dominant-200 bg-white dark:bg-dominant-800 opacity-0 rounded-lg border border-dominant-200 dark:border-dominant-700 shadow-lg invisible scale-95 transition-all duration-150 origin-top-left peer-aria-expanded:visible peer-aria-expanded:scale-100 peer-aria-expanded:opacity-100"
>
<span>Choose every category that applies. The panel stays open so you can pick several.</span>
</div>
</div>
<div class="relative">
<div
class="h-10 flex flex-nowrap items-center gap-1.5 overflow-hidden inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 pr-16 pl-2.5 w-full bg-white dark:bg-dominant-950 rounded-lg focus-within:inset-ring-primary-500 dark:focus-within:inset-ring-primary-400 focus-within:ring-2 focus-within:ring-primary-500/30 dark:focus-within:ring-primary-400/30 has-[button[aria-invalid=true]]:inset-ring-danger-600 dark:has-[button[aria-invalid=true]]:inset-ring-danger-400 has-[button[aria-invalid=true]]:focus-within:inset-ring-danger-600 dark:has-[button[aria-invalid=true]]:focus-within:inset-ring-danger-400 has-[button[aria-invalid=true]]:focus-within:ring-danger-600/30 dark:has-[button[aria-invalid=true]]:focus-within:ring-danger-400/30"
>
<template x-for="item in chips" x-bind:key="item.value">
<span
class="relative z-1 inline-flex shrink items-center gap-1 py-0.5 pr-1 pl-2 min-w-0 text-sm font-medium text-dominant-900 dark:text-dominant-100 bg-dominant-200 dark:bg-dominant-700 rounded-md"
>
<span x-text="item.text" class="truncate"> </span>
<button
type="button"
x-bind:aria-label="'Remove ' + item.text"
x-on:click="remove(item)"
class="flex shrink-0 items-center justify-center size-5 text-xs rounded cursor-pointer transition-colors hover:bg-dominant-300 dark:hover:bg-dominant-600 focus-visible:ring-2 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
</span>
</template>
<template x-if="hiddenCount">
<span
aria-hidden="true"
x-text="'+' + hiddenCount"
class="inline-flex shrink-0 items-center px-2 py-0.5 text-sm font-medium text-dominant-900 dark:text-dominant-100 bg-dominant-200 dark:bg-dominant-700 rounded-md"
>
</span>
</template>
<button
id="searchable-categories"
class="flex-1 px-1 py-1 min-w-0 truncate text-left text-sm text-dominant-600 dark:text-dominant-400 bg-transparent rounded cursor-pointer focus:outline-none after:absolute after:inset-0 after:content-['']"
x-ref="trigger"
type="button"
aria-haspopup="listbox"
aria-controls="searchable-categories-panel"
aria-expanded="false"
x-bind:aria-invalid="showError ? 'true' : null"
x-bind:aria-required="required ? 'true' : null"
x-bind:disabled="disabled"
x-on:click="onTrigger()"
x-on:keydown.down.prevent="onArrow()"
x-bind:aria-describedby="['searchable-categories-hint', showError ? 'searchable-categories-error' : null].filter(Boolean).join(' ') || null"
aria-labelledby="searchable-categories-label"
>
<span
data-placeholder="Add a category…"
x-bind:class="{ 'sr-only': hasValue }"
x-text="hasValue ? summary : $el.dataset.placeholder"
>Add a category…</span
>
</button>
<button
type="button"
aria-label="Clear all Categories"
title="Clear all"
x-bind:hidden="!hasValue"
x-on:click="clear()"
class="absolute top-1/2 right-9 flex items-center justify-center size-6 text-xs text-dominant-600 dark:text-dominant-300 rounded-full cursor-pointer transition-colors -translate-y-1/2 hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
<i
aria-hidden="true"
class="absolute top-1/2 right-3.5 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-chevron-down"
>
</i>
</div>
</div>
<div
id="searchable-categories-panel"
class="absolute z-10 mt-1 w-full bg-white dark:bg-dominant-800 rounded-lg border border-dominant-200 dark:border-dominant-700 opacity-0 shadow-lg invisible origin-top scale-95 transition-all duration-150 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:visible group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:scale-100 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:opacity-100"
>
<div class="p-2 border-b border-dominant-200 dark:border-dominant-700">
<div class="relative">
<i
aria-hidden="true"
class="absolute top-1/2 left-3 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-magnifying-glass"
>
</i>
<input
x-ref="search"
x-model="query"
type="text"
role="combobox"
autocomplete="off"
aria-autocomplete="list"
aria-expanded="true"
aria-controls="searchable-categories-list"
x-bind:aria-activedescendant="activeId"
aria-label="Search Categories"
placeholder="Search…"
x-on:input="onInput()"
x-on:keydown.down.prevent="move(1)"
x-on:keydown.up.prevent="move(-1)"
x-on:keydown.enter.prevent="onEnter()"
class="block inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 px-3 py-1.5 pl-9 w-full text-dominant-900 dark:text-white text-sm bg-white dark:bg-dominant-950 rounded-lg placeholder:text-dominant-600 dark:placeholder:text-dominant-400 focus:inset-ring-primary-500 dark:focus:inset-ring-primary-400 focus:ring-2 focus:ring-primary-500/30 dark:focus:ring-primary-400/30 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50"
/>
</div>
</div>
<div x-ref="scroller" x-on:scroll="onScroll($event)" class="overflow-y-auto max-h-60">
<ul
id="searchable-categories-list"
role="listbox"
aria-labelledby="searchable-categories-label"
aria-multiselectable="true"
class="p-1"
>
<template x-for="(option, index) in visible" x-bind:key="option.value">
<li
role="option"
x-bind:id="optionId(index)"
x-bind:aria-selected="String(isSelected(option))"
x-on:click="choose(option)"
x-on:mousemove="active = index"
x-bind:class="index === active ? 'bg-dominant-100 dark:bg-dominant-700' : ''"
class="flex items-center gap-3 px-3 py-2 text-sm text-dominant-900 dark:text-dominant-100 rounded-md cursor-pointer"
>
<span class="flex-1 min-w-0">
<span x-text="option.text" class="block truncate"> </span>
<template x-if="option.description">
<span
x-text="option.description"
class="block truncate text-xs text-dominant-600 dark:text-dominant-200"
>
</span>
</template>
</span>
<template x-if="isSelected(option)">
<i
aria-hidden="true"
class="text-xs text-dominant-900 dark:text-white fa-solid fa-check"
>
</i>
</template>
</li>
</template>
</ul>
<p
x-bind:hidden="!message"
class="flex items-center gap-2 px-3 py-2 text-sm text-dominant-600 dark:text-dominant-300"
>
<i x-bind:hidden="!loading" aria-hidden="true" class="text-xs fa-solid fa-spinner fa-spin">
</i>
<span x-text="message"> </span>
<button
id="searchable-categories-retry"
type="button"
x-bind:hidden="!error"
x-on:click="retry()"
class="font-semibold rounded underline-offset-2 focus-visible:ring-2 focus-visible:outline-none cursor-pointer text-primary-700 dark:text-primary-300 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 underline hover:text-primary-800 dark:hover:text-primary-200 ml-auto"
>
<span>Try again</span>
</button>
</p>
</div>
<p role="status" x-text="status" class="sr-only"></p>
</div>
<select
id="searchable-categories-select"
name="categories[]"
x-ref="select"
tabindex="-1"
aria-hidden="true"
multiple="true"
required="true"
x-on:invalid.prevent="onInvalid($event)"
class="sr-only"
>
<template x-if="!multiple">
<option value x-bind:selected="!hasValue"></option>
</template>
<template x-for="item in selected" x-bind:key="item.value">
<option x-bind:value="item.value" selected x-text="item.text"></option>
</template>
</select>
<template x-if="showError">
<p
id="searchable-categories-error"
class="flex items-start gap-1.5 mt-1.5 text-sm font-medium text-danger-700 dark:text-danger-300"
>
<i aria-hidden="true" class="mt-0.5 fa-solid fa-circle-exclamation"> </i>
<span>Select an option.</span>
</p>
</template>
</div>
Adapting to your server
The component is a client: it never assumes more than a contract, and it does not force one on your project. By default it speaks the Starkit contract (see Remote data). When your server differs, set only the option that differs: headers (token), params (query string), parse (items and nextPage, null when there is no next page), map (one item to value, text, label, description). A page is a number or a token: firstPage is null (not sent), and the nextPage you return is what params receives next; null means there is no next page, and the component never guesses it, so return it even for page numbers. What the template sends is what params returns: an empty string is sent empty, null and undefined are not sent. When nothing fits, request replaces everything. The fields below talk to a live Laravel paginator endpoint, with only params, parse and map set; the table compares it with the Starkit contract and with a cursor server.
| What differs | Starkit contract | Laravel paginator | A cursor server | Change this option |
|---|---|---|---|---|
| Query names |
page, limit, search, filters[field], sorts[field]
|
page, search, order_by
|
query, limit, after
|
params
|
| How paging works | page numbers | page numbers | a cursor taken from the previous answer |
params (the page argument) and parse (nextPage)
|
| Where the items are |
response.data
|
response.data
|
response.results
|
parse
|
| Is there another page? |
the page of links.next
|
the page of next_page_url
|
next is not null
|
parse (nextPage: null when there is none)
|
| Item fields |
id, name, description
|
id, name, description
|
code, title, department
|
map
|
| Token, cookies, extra headers | none | none | bearer token |
headers
|
| Nothing fits | – | – | – |
request replaces all of the above
|
Select an option.
Select an option.
<div
id="table-1480-wrapper"
class="isolate overflow-auto rounded-xl border border-dominant-200 dark:border-dominant-700 focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:outline-none dark:focus-visible:ring-primary-400"
tabindex="0"
>
<table
id="table-1480"
class="w-full border-separate border-spacing-0 text-left text-sm [&_th]:px-4 [&_td]:px-4 [&_th]:whitespace-nowrap [&_td]:whitespace-nowrap [&_td]:text-dominant-700 dark:[&_td]:text-dominant-200 [&_tbody_th]:font-medium [&_tbody_th]:text-dominant-900 dark:[&_tbody_th]:text-white [&_thead_th]:text-xs [&_thead_th]:font-semibold [&_thead_th]:tracking-wide [&_thead_th]:uppercase [&_thead_tr:last-child>*]:border-b [&_thead_tr:last-child>*]:border-dominant-300 dark:[&_thead_tr:last-child>*]:border-dominant-600 [&_tbody>tr+tr>*]:border-t [&_tbody>tr>*]:border-dominant-200 dark:[&_tbody>tr>*]:border-dominant-700 [&_tfoot>tr>*]:border-t [&_tfoot>tr>*]:border-dominant-300 dark:[&_tfoot>tr>*]:border-dominant-600 [&_tfoot>tr>*]:font-semibold [&_thead_th]:bg-dominant-200 dark:[&_thead_th]:bg-dominant-700 [&_thead_th]:text-dominant-800 dark:[&_thead_th]:text-dominant-100 [&_thead_td]:bg-dominant-100 dark:[&_thead_td]:bg-dominant-800 [&_tfoot>tr>*]:bg-dominant-100 dark:[&_tfoot>tr>*]:bg-dominant-800 [&_tfoot>tr>*]:text-dominant-900 dark:[&_tfoot>tr>*]:text-white [&_.table-sticky-left]:sticky [&_.table-sticky-right]:sticky [&_tbody_.table-sticky-left]:z-10 [&_tbody_.table-sticky-right]:z-10 [&_tbody_.table-sticky-left]:bg-white dark:[&_tbody_.table-sticky-left]:bg-dominant-900 [&_tbody_.table-sticky-right]:bg-white dark:[&_tbody_.table-sticky-right]:bg-dominant-900 [&_thead_th.table-sticky-left]:z-30 [&_thead_th.table-sticky-right]:z-30 [&_thead_td.table-sticky-left]:z-10 [&_thead_td.table-sticky-right]:z-10 [&_th]:py-3 [&_td]:py-3"
>
<thead>
<tr>
<th scope="col">What differs</th>
<th scope="col">Starkit contract</th>
<th scope="col">Laravel paginator</th>
<th scope="col">A cursor server</th>
<th scope="col">Change this option</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Query names</th>
<td>
<code>page</code>, <code>limit</code>, <code>search</code>, <code>filters[field]</code>,
<code>sorts[field]</code>
</td>
<td><code>page</code>, <code>search</code>, <code>order_by</code></td>
<td><code>query</code>, <code>limit</code>, <code>after</code></td>
<td>
<code>params</code>
</td>
</tr>
<tr>
<th scope="row">How paging works</th>
<td>page numbers</td>
<td>page numbers</td>
<td>a cursor taken from the previous answer</td>
<td>
<code>params</code> (the <code>page</code> argument) and
<code>parse</code> (<code>nextPage</code>)
</td>
</tr>
<tr>
<th scope="row">Where the items are</th>
<td>
<code>response.data</code>
</td>
<td>
<code>response.data</code>
</td>
<td>
<code>response.results</code>
</td>
<td>
<code>parse</code>
</td>
</tr>
<tr>
<th scope="row">Is there another page?</th>
<td>the <code>page</code> of <code>links.next</code></td>
<td>the <code>page</code> of <code>next_page_url</code></td>
<td><code>next</code> is not <code>null</code></td>
<td><code>parse</code> (<code>nextPage</code>: <code>null</code> when there is none)</td>
</tr>
<tr>
<th scope="row">Item fields</th>
<td><code>id</code>, <code>name</code>, <code>description</code></td>
<td><code>id</code>, <code>name</code>, <code>description</code></td>
<td><code>code</code>, <code>title</code>, <code>department</code></td>
<td>
<code>map</code>
</td>
</tr>
<tr>
<th scope="row">Token, cookies, extra headers</th>
<td>none</td>
<td>none</td>
<td>bearer token</td>
<td>
<code>headers</code>
</td>
</tr>
<tr>
<th scope="row">Nothing fits</th>
<td>–</td>
<td>–</td>
<td>–</td>
<td><code>request</code> replaces all of the above</td>
</tr>
</tbody>
</table>
</div>
<div class="grid grid-cols-1 gap-5 mt-5 sm:grid-cols-2">
<div
id="searchable-paginator-category-field"
x-data='searchableSelect(Object.assign({"url":"https://starkit-template.netlify.app/api/laravel-paginator/categories","minChars":2}, {
firstPage: 1,
params: (term, page) => ({ page: page, search: term || null, order_by: 'name' }),
parse: (response) => ({ items: response.data, nextPage: response.next_page_url ? new URL(response.next_page_url).searchParams.get('page') : null }),
map: (category) => ({ value: category.id, text: category.name, description: category.description }),
}))'
x-on:focusout="onFocusOut($event)"
class="relative group/combo"
>
<div class="flex items-center gap-1 mb-1.5">
<label
id="searchable-paginator-category-label"
for="searchable-paginator-category"
class="block text-sm font-medium text-dominant-700 dark:text-dominant-200"
>
<span>Category</span>
</label>
<button
id="searchable-paginator-category-hint-button"
type="button"
aria-controls="searchable-paginator-category-hint"
aria-expanded="false"
aria-haspopup="true"
aria-label="Hint for Category"
class="flex shrink-0 items-center justify-center size-6 text-dominant-600 dark:text-dominant-300 rounded-full cursor-pointer transition-colors peer hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-circle-question"> </i>
</button>
<div
id="searchable-paginator-category-hint"
class="absolute top-7 left-0 z-10 p-3 w-full max-w-xs text-sm text-dominant-700 dark:text-dominant-200 bg-white dark:bg-dominant-800 opacity-0 rounded-lg border border-dominant-200 dark:border-dominant-700 shadow-lg invisible scale-95 transition-all duration-150 origin-top-left peer-aria-expanded:visible peer-aria-expanded:scale-100 peer-aria-expanded:opacity-100"
>
<span>Choose the category this item belongs to. Type to search by name.</span>
</div>
</div>
<div class="relative">
<button
id="searchable-paginator-category"
class="block inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 pr-16 w-full text-dominant-900 dark:text-white text-left bg-white dark:bg-dominant-950 rounded-lg cursor-pointer placeholder:text-dominant-600 dark:placeholder:text-dominant-400 focus:inset-ring-primary-500 dark:focus:inset-ring-primary-400 focus:ring-2 focus:ring-primary-500/30 dark:focus:ring-primary-400/30 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:inset-ring-danger-600 dark:aria-invalid:inset-ring-danger-400 aria-invalid:focus:inset-ring-danger-600 dark:aria-invalid:focus:inset-ring-danger-400 aria-invalid:focus:ring-danger-600/30 dark:aria-invalid:focus:ring-danger-400/30 px-3.5 py-2.5 text-sm"
x-ref="trigger"
type="button"
aria-haspopup="listbox"
aria-controls="searchable-paginator-category-panel"
aria-expanded="false"
x-bind:aria-invalid="showError ? 'true' : null"
x-bind:aria-required="required ? 'true' : null"
x-bind:disabled="disabled"
x-on:click="onTrigger()"
x-on:keydown.down.prevent="onArrow()"
x-bind:aria-describedby="['searchable-paginator-category-hint', showError ? 'searchable-paginator-category-error' : null].filter(Boolean).join(' ') || null"
aria-labelledby="searchable-paginator-category-label searchable-paginator-category-value"
>
<span
id="searchable-paginator-category-value"
x-bind:class="hasValue ? '' : 'text-dominant-600 dark:text-dominant-400'"
data-placeholder="Select a category"
x-text="hasValue ? selected[0].text : $el.dataset.placeholder"
class="block truncate"
>Select a category</span
>
</button>
<button
type="button"
aria-label="Clear Category"
x-bind:hidden="!hasValue || disabled"
x-on:click="clear()"
class="absolute top-1/2 right-9 flex items-center justify-center size-6 text-xs text-dominant-600 dark:text-dominant-300 rounded-full cursor-pointer transition-colors -translate-y-1/2 hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
<i
aria-hidden="true"
class="absolute top-1/2 right-3.5 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-chevron-down"
>
</i>
</div>
<div
id="searchable-paginator-category-panel"
class="absolute z-10 mt-1 w-full bg-white dark:bg-dominant-800 rounded-lg border border-dominant-200 dark:border-dominant-700 opacity-0 shadow-lg invisible origin-top scale-95 transition-all duration-150 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:visible group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:scale-100 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:opacity-100"
>
<div class="p-2 border-b border-dominant-200 dark:border-dominant-700">
<div class="relative">
<i
aria-hidden="true"
class="absolute top-1/2 left-3 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-magnifying-glass"
>
</i>
<input
x-ref="search"
x-model="query"
type="text"
role="combobox"
autocomplete="off"
aria-autocomplete="list"
aria-expanded="true"
aria-controls="searchable-paginator-category-list"
x-bind:aria-activedescendant="activeId"
aria-label="Search Category"
placeholder="Search…"
x-on:input="onInput()"
x-on:keydown.down.prevent="move(1)"
x-on:keydown.up.prevent="move(-1)"
x-on:keydown.enter.prevent="onEnter()"
class="block inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 px-3 py-1.5 pl-9 w-full text-dominant-900 dark:text-white text-sm bg-white dark:bg-dominant-950 rounded-lg placeholder:text-dominant-600 dark:placeholder:text-dominant-400 focus:inset-ring-primary-500 dark:focus:inset-ring-primary-400 focus:ring-2 focus:ring-primary-500/30 dark:focus:ring-primary-400/30 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50"
/>
</div>
</div>
<div x-ref="scroller" x-on:scroll="onScroll($event)" class="overflow-y-auto max-h-60">
<ul
id="searchable-paginator-category-list"
role="listbox"
aria-labelledby="searchable-paginator-category-label"
class="p-1"
>
<template x-for="(option, index) in visible" x-bind:key="option.value">
<li
role="option"
x-bind:id="optionId(index)"
x-bind:aria-selected="String(isSelected(option))"
x-on:click="choose(option)"
x-on:mousemove="active = index"
x-bind:class="index === active ? 'bg-dominant-100 dark:bg-dominant-700' : ''"
class="flex items-center gap-3 px-3 py-2 text-sm text-dominant-900 dark:text-dominant-100 rounded-md cursor-pointer"
>
<span class="flex-1 min-w-0">
<span x-text="option.text" class="block truncate"> </span>
<template x-if="option.description">
<span
x-text="option.description"
class="block truncate text-xs text-dominant-600 dark:text-dominant-200"
>
</span>
</template>
</span>
<template x-if="isSelected(option)">
<i
aria-hidden="true"
class="text-xs text-dominant-900 dark:text-white fa-solid fa-check"
>
</i>
</template>
</li>
</template>
</ul>
<p
x-bind:hidden="!message"
class="flex items-center gap-2 px-3 py-2 text-sm text-dominant-600 dark:text-dominant-300"
>
<i
x-bind:hidden="!loading"
aria-hidden="true"
class="text-xs fa-solid fa-spinner fa-spin"
>
</i>
<span x-text="message"> </span>
<button
id="searchable-paginator-category-retry"
type="button"
x-bind:hidden="!error"
x-on:click="retry()"
class="font-semibold rounded underline-offset-2 focus-visible:ring-2 focus-visible:outline-none cursor-pointer text-primary-700 dark:text-primary-300 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 underline hover:text-primary-800 dark:hover:text-primary-200 ml-auto"
>
<span>Try again</span>
</button>
</p>
</div>
<p role="status" x-text="status" class="sr-only"></p>
</div>
<select
id="searchable-paginator-category-select"
name="category"
x-ref="select"
tabindex="-1"
aria-hidden="true"
x-on:invalid.prevent="onInvalid($event)"
class="sr-only"
>
<template x-if="!multiple">
<option value x-bind:selected="!hasValue"></option>
</template>
<template x-for="item in selected" x-bind:key="item.value">
<option x-bind:value="item.value" selected x-text="item.text"></option>
</template>
</select>
<template x-if="showError">
<p
id="searchable-paginator-category-error"
class="flex items-start gap-1.5 mt-1.5 text-sm font-medium text-danger-700 dark:text-danger-300"
>
<i aria-hidden="true" class="mt-0.5 fa-solid fa-circle-exclamation"> </i>
<span>Select an option.</span>
</p>
</template>
</div>
<div
id="searchable-paginator-categories-field"
x-data='searchableSelect(Object.assign({"url":"https://starkit-template.netlify.app/api/laravel-paginator/categories","multiple":true}, {
params: (term, page) => ({ page: page, search: term || null, order_by: 'name' }),
parse: (response) => ({ items: response.data, nextPage: response.next_page_url ? new URL(response.next_page_url).searchParams.get('page') : null }),
map: (category) => ({ value: category.id, text: category.name, description: category.description }),
}))'
x-on:focusout="onFocusOut($event)"
class="relative group/combo"
>
<div class="flex items-center gap-1 mb-1.5">
<label
id="searchable-paginator-categories-label"
for="searchable-paginator-categories"
class="block text-sm font-medium text-dominant-700 dark:text-dominant-200"
>
<span>Categories</span>
</label>
<button
id="searchable-paginator-categories-hint-button"
type="button"
aria-controls="searchable-paginator-categories-hint"
aria-expanded="false"
aria-haspopup="true"
aria-label="Hint for Categories"
class="flex shrink-0 items-center justify-center size-6 text-dominant-600 dark:text-dominant-300 rounded-full cursor-pointer transition-colors peer hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-circle-question"> </i>
</button>
<div
id="searchable-paginator-categories-hint"
class="absolute top-7 left-0 z-10 p-3 w-full max-w-xs text-sm text-dominant-700 dark:text-dominant-200 bg-white dark:bg-dominant-800 opacity-0 rounded-lg border border-dominant-200 dark:border-dominant-700 shadow-lg invisible scale-95 transition-all duration-150 origin-top-left peer-aria-expanded:visible peer-aria-expanded:scale-100 peer-aria-expanded:opacity-100"
>
<span
>Choose every category that applies. The panel stays open so you can pick several.</span
>
</div>
</div>
<div class="relative">
<div
class="h-10 flex flex-nowrap items-center gap-1.5 overflow-hidden inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 pr-16 pl-2.5 w-full bg-white dark:bg-dominant-950 rounded-lg focus-within:inset-ring-primary-500 dark:focus-within:inset-ring-primary-400 focus-within:ring-2 focus-within:ring-primary-500/30 dark:focus-within:ring-primary-400/30 has-[button[aria-invalid=true]]:inset-ring-danger-600 dark:has-[button[aria-invalid=true]]:inset-ring-danger-400 has-[button[aria-invalid=true]]:focus-within:inset-ring-danger-600 dark:has-[button[aria-invalid=true]]:focus-within:inset-ring-danger-400 has-[button[aria-invalid=true]]:focus-within:ring-danger-600/30 dark:has-[button[aria-invalid=true]]:focus-within:ring-danger-400/30"
>
<template x-for="item in chips" x-bind:key="item.value">
<span
class="relative z-1 inline-flex shrink items-center gap-1 py-0.5 pr-1 pl-2 min-w-0 text-sm font-medium text-dominant-900 dark:text-dominant-100 bg-dominant-200 dark:bg-dominant-700 rounded-md"
>
<span x-text="item.text" class="truncate"> </span>
<button
type="button"
x-bind:aria-label="'Remove ' + item.text"
x-on:click="remove(item)"
class="flex shrink-0 items-center justify-center size-5 text-xs rounded cursor-pointer transition-colors hover:bg-dominant-300 dark:hover:bg-dominant-600 focus-visible:ring-2 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
</span>
</template>
<template x-if="hiddenCount">
<span
aria-hidden="true"
x-text="'+' + hiddenCount"
class="inline-flex shrink-0 items-center px-2 py-0.5 text-sm font-medium text-dominant-900 dark:text-dominant-100 bg-dominant-200 dark:bg-dominant-700 rounded-md"
>
</span>
</template>
<button
id="searchable-paginator-categories"
class="flex-1 px-1 py-1 min-w-0 truncate text-left text-sm text-dominant-600 dark:text-dominant-400 bg-transparent rounded cursor-pointer focus:outline-none after:absolute after:inset-0 after:content-['']"
x-ref="trigger"
type="button"
aria-haspopup="listbox"
aria-controls="searchable-paginator-categories-panel"
aria-expanded="false"
x-bind:aria-invalid="showError ? 'true' : null"
x-bind:aria-required="required ? 'true' : null"
x-bind:disabled="disabled"
x-on:click="onTrigger()"
x-on:keydown.down.prevent="onArrow()"
x-bind:aria-describedby="['searchable-paginator-categories-hint', showError ? 'searchable-paginator-categories-error' : null].filter(Boolean).join(' ') || null"
aria-labelledby="searchable-paginator-categories-label"
>
<span
data-placeholder="Add an option…"
x-bind:class="{ 'sr-only': hasValue }"
x-text="hasValue ? summary : $el.dataset.placeholder"
>Add an option…</span
>
</button>
<button
type="button"
aria-label="Clear all Categories"
title="Clear all"
x-bind:hidden="!hasValue"
x-on:click="clear()"
class="absolute top-1/2 right-9 flex items-center justify-center size-6 text-xs text-dominant-600 dark:text-dominant-300 rounded-full cursor-pointer transition-colors -translate-y-1/2 hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
<i
aria-hidden="true"
class="absolute top-1/2 right-3.5 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-chevron-down"
>
</i>
</div>
</div>
<div
id="searchable-paginator-categories-panel"
class="absolute z-10 mt-1 w-full bg-white dark:bg-dominant-800 rounded-lg border border-dominant-200 dark:border-dominant-700 opacity-0 shadow-lg invisible origin-top scale-95 transition-all duration-150 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:visible group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:scale-100 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:opacity-100"
>
<div class="p-2 border-b border-dominant-200 dark:border-dominant-700">
<div class="relative">
<i
aria-hidden="true"
class="absolute top-1/2 left-3 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-magnifying-glass"
>
</i>
<input
x-ref="search"
x-model="query"
type="text"
role="combobox"
autocomplete="off"
aria-autocomplete="list"
aria-expanded="true"
aria-controls="searchable-paginator-categories-list"
x-bind:aria-activedescendant="activeId"
aria-label="Search Categories"
placeholder="Search…"
x-on:input="onInput()"
x-on:keydown.down.prevent="move(1)"
x-on:keydown.up.prevent="move(-1)"
x-on:keydown.enter.prevent="onEnter()"
class="block inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 px-3 py-1.5 pl-9 w-full text-dominant-900 dark:text-white text-sm bg-white dark:bg-dominant-950 rounded-lg placeholder:text-dominant-600 dark:placeholder:text-dominant-400 focus:inset-ring-primary-500 dark:focus:inset-ring-primary-400 focus:ring-2 focus:ring-primary-500/30 dark:focus:ring-primary-400/30 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50"
/>
</div>
</div>
<div x-ref="scroller" x-on:scroll="onScroll($event)" class="overflow-y-auto max-h-60">
<ul
id="searchable-paginator-categories-list"
role="listbox"
aria-labelledby="searchable-paginator-categories-label"
aria-multiselectable="true"
class="p-1"
>
<template x-for="(option, index) in visible" x-bind:key="option.value">
<li
role="option"
x-bind:id="optionId(index)"
x-bind:aria-selected="String(isSelected(option))"
x-on:click="choose(option)"
x-on:mousemove="active = index"
x-bind:class="index === active ? 'bg-dominant-100 dark:bg-dominant-700' : ''"
class="flex items-center gap-3 px-3 py-2 text-sm text-dominant-900 dark:text-dominant-100 rounded-md cursor-pointer"
>
<span class="flex-1 min-w-0">
<span x-text="option.text" class="block truncate"> </span>
<template x-if="option.description">
<span
x-text="option.description"
class="block truncate text-xs text-dominant-600 dark:text-dominant-200"
>
</span>
</template>
</span>
<template x-if="isSelected(option)">
<i
aria-hidden="true"
class="text-xs text-dominant-900 dark:text-white fa-solid fa-check"
>
</i>
</template>
</li>
</template>
</ul>
<p
x-bind:hidden="!message"
class="flex items-center gap-2 px-3 py-2 text-sm text-dominant-600 dark:text-dominant-300"
>
<i
x-bind:hidden="!loading"
aria-hidden="true"
class="text-xs fa-solid fa-spinner fa-spin"
>
</i>
<span x-text="message"> </span>
<button
id="searchable-paginator-categories-retry"
type="button"
x-bind:hidden="!error"
x-on:click="retry()"
class="font-semibold rounded underline-offset-2 focus-visible:ring-2 focus-visible:outline-none cursor-pointer text-primary-700 dark:text-primary-300 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 underline hover:text-primary-800 dark:hover:text-primary-200 ml-auto"
>
<span>Try again</span>
</button>
</p>
</div>
<p role="status" x-text="status" class="sr-only"></p>
</div>
<select
id="searchable-paginator-categories-select"
name="categories"
x-ref="select"
tabindex="-1"
aria-hidden="true"
multiple="true"
x-on:invalid.prevent="onInvalid($event)"
class="sr-only"
>
<template x-if="!multiple">
<option value x-bind:selected="!hasValue"></option>
</template>
<template x-for="item in selected" x-bind:key="item.value">
<option x-bind:value="item.value" selected x-text="item.text"></option>
</template>
</select>
<template x-if="showError">
<p
id="searchable-paginator-categories-error"
class="flex items-start gap-1.5 mt-1.5 text-sm font-medium text-danger-700 dark:text-danger-300"
>
<i aria-hidden="true" class="mt-0.5 fa-solid fa-circle-exclamation"> </i>
<span>Select an option.</span>
</p>
</template>
</div>
</div>
States
disabled turns the button off and keeps the panel closed. error shows a message from the server at once; the button gets aria-invalid="true" and a red frame. The three rows below show what a remote list does while it waits, when it has nothing to show and when the request fails.
Select an option.
We do not ship to this country yet. Choose another one.
Select an option.
Select an option.
Select an option.
<div class="grid grid-cols-1 gap-6 sm:grid-cols-2">
<div>
<div
id="searchable-disabled-field"
x-data="searchableSelect(Object.assign({}, {}))"
x-on:focusout="onFocusOut($event)"
class="relative group/combo"
>
<div class="flex items-center gap-1 mb-1.5">
<label
id="searchable-disabled-label"
for="searchable-disabled"
class="block text-sm font-medium text-dominant-700 dark:text-dominant-200"
>
<span>Disabled</span>
</label>
</div>
<div class="relative">
<button
id="searchable-disabled"
class="block inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 pr-16 w-full text-dominant-900 dark:text-white text-left bg-white dark:bg-dominant-950 rounded-lg cursor-pointer placeholder:text-dominant-600 dark:placeholder:text-dominant-400 focus:inset-ring-primary-500 dark:focus:inset-ring-primary-400 focus:ring-2 focus:ring-primary-500/30 dark:focus:ring-primary-400/30 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:inset-ring-danger-600 dark:aria-invalid:inset-ring-danger-400 aria-invalid:focus:inset-ring-danger-600 dark:aria-invalid:focus:inset-ring-danger-400 aria-invalid:focus:ring-danger-600/30 dark:aria-invalid:focus:ring-danger-400/30 px-3.5 py-2.5 text-sm"
x-ref="trigger"
type="button"
aria-haspopup="listbox"
aria-controls="searchable-disabled-panel"
aria-expanded="false"
x-bind:aria-invalid="showError ? 'true' : null"
x-bind:aria-required="required ? 'true' : null"
x-bind:disabled="disabled"
x-on:click="onTrigger()"
x-on:keydown.down.prevent="onArrow()"
x-bind:aria-describedby="[showError ? 'searchable-disabled-error' : null].filter(Boolean).join(' ') || null"
aria-labelledby="searchable-disabled-label searchable-disabled-value"
>
<span
id="searchable-disabled-value"
x-bind:class="hasValue ? '' : 'text-dominant-600 dark:text-dominant-400'"
data-placeholder="Select a country"
x-text="hasValue ? selected[0].text : $el.dataset.placeholder"
class="block truncate"
>Select a country</span
>
</button>
<button
type="button"
aria-label="Clear Disabled"
x-bind:hidden="!hasValue || disabled"
x-on:click="clear()"
class="absolute top-1/2 right-9 flex items-center justify-center size-6 text-xs text-dominant-600 dark:text-dominant-300 rounded-full cursor-pointer transition-colors -translate-y-1/2 hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
<i
aria-hidden="true"
class="absolute top-1/2 right-3.5 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-chevron-down"
>
</i>
</div>
<div
id="searchable-disabled-panel"
class="absolute z-10 mt-1 w-full bg-white dark:bg-dominant-800 rounded-lg border border-dominant-200 dark:border-dominant-700 opacity-0 shadow-lg invisible origin-top scale-95 transition-all duration-150 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:visible group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:scale-100 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:opacity-100"
>
<div class="p-2 border-b border-dominant-200 dark:border-dominant-700">
<div class="relative">
<i
aria-hidden="true"
class="absolute top-1/2 left-3 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-magnifying-glass"
>
</i>
<input
x-ref="search"
x-model="query"
type="text"
role="combobox"
autocomplete="off"
aria-autocomplete="list"
aria-expanded="true"
aria-controls="searchable-disabled-list"
x-bind:aria-activedescendant="activeId"
aria-label="Search Disabled"
placeholder="Search…"
x-on:input="onInput()"
x-on:keydown.down.prevent="move(1)"
x-on:keydown.up.prevent="move(-1)"
x-on:keydown.enter.prevent="onEnter()"
class="block inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 px-3 py-1.5 pl-9 w-full text-dominant-900 dark:text-white text-sm bg-white dark:bg-dominant-950 rounded-lg placeholder:text-dominant-600 dark:placeholder:text-dominant-400 focus:inset-ring-primary-500 dark:focus:inset-ring-primary-400 focus:ring-2 focus:ring-primary-500/30 dark:focus:ring-primary-400/30 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50"
/>
</div>
</div>
<div x-ref="scroller" x-on:scroll="onScroll($event)" class="overflow-y-auto max-h-60">
<ul
id="searchable-disabled-list"
role="listbox"
aria-labelledby="searchable-disabled-label"
class="p-1"
>
<template x-for="(option, index) in visible" x-bind:key="option.value">
<li
role="option"
x-bind:id="optionId(index)"
x-bind:aria-selected="String(isSelected(option))"
x-on:click="choose(option)"
x-on:mousemove="active = index"
x-bind:class="index === active ? 'bg-dominant-100 dark:bg-dominant-700' : ''"
class="flex items-center gap-3 px-3 py-2 text-sm text-dominant-900 dark:text-dominant-100 rounded-md cursor-pointer"
>
<span class="flex-1 min-w-0">
<span x-text="option.text" class="block truncate"> </span>
<template x-if="option.description">
<span
x-text="option.description"
class="block truncate text-xs text-dominant-600 dark:text-dominant-200"
>
</span>
</template>
</span>
<template x-if="isSelected(option)">
<i
aria-hidden="true"
class="text-xs text-dominant-900 dark:text-white fa-solid fa-check"
>
</i>
</template>
</li>
</template>
</ul>
<p
x-bind:hidden="!message"
class="flex items-center gap-2 px-3 py-2 text-sm text-dominant-600 dark:text-dominant-300"
>
<i
x-bind:hidden="!loading"
aria-hidden="true"
class="text-xs fa-solid fa-spinner fa-spin"
>
</i>
<span x-text="message"> </span>
<button
id="searchable-disabled-retry"
type="button"
x-bind:hidden="!error"
x-on:click="retry()"
class="font-semibold rounded underline-offset-2 focus-visible:ring-2 focus-visible:outline-none cursor-pointer text-primary-700 dark:text-primary-300 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 underline hover:text-primary-800 dark:hover:text-primary-200 ml-auto"
>
<span>Try again</span>
</button>
</p>
</div>
<p role="status" x-text="status" class="sr-only"></p>
</div>
<select
id="searchable-disabled-select"
name="disabled"
x-ref="select"
tabindex="-1"
aria-hidden="true"
disabled="true"
x-on:invalid.prevent="onInvalid($event)"
class="sr-only"
>
<option value="ca">Canada</option>
<option value="de">Germany</option>
<option value="jp">Japan</option>
<template x-if="!multiple">
<option value x-bind:selected="!hasValue"></option>
</template>
<template x-for="item in selected" x-bind:key="item.value">
<option x-bind:value="item.value" selected x-text="item.text"></option>
</template>
</select>
<template x-if="showError">
<p
id="searchable-disabled-error"
class="flex items-start gap-1.5 mt-1.5 text-sm font-medium text-danger-700 dark:text-danger-300"
>
<i aria-hidden="true" class="mt-0.5 fa-solid fa-circle-exclamation"> </i>
<span>Select an option.</span>
</p>
</template>
</div>
</div>
<div>
<div
id="searchable-invalid-field"
x-data='searchableSelect(Object.assign({"value":["jp"],"error":true}, {}))'
x-on:focusout="onFocusOut($event)"
class="relative group/combo"
>
<div class="flex items-center gap-1 mb-1.5">
<label
id="searchable-invalid-label"
for="searchable-invalid"
class="block text-sm font-medium text-dominant-700 dark:text-dominant-200"
>
<span>Error from the server</span>
<span aria-hidden="true" class="text-danger-700 dark:text-danger-300">*</span>
</label>
</div>
<div class="relative">
<button
id="searchable-invalid"
class="block inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 pr-16 w-full text-dominant-900 dark:text-white text-left bg-white dark:bg-dominant-950 rounded-lg cursor-pointer placeholder:text-dominant-600 dark:placeholder:text-dominant-400 focus:inset-ring-primary-500 dark:focus:inset-ring-primary-400 focus:ring-2 focus:ring-primary-500/30 dark:focus:ring-primary-400/30 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:inset-ring-danger-600 dark:aria-invalid:inset-ring-danger-400 aria-invalid:focus:inset-ring-danger-600 dark:aria-invalid:focus:inset-ring-danger-400 aria-invalid:focus:ring-danger-600/30 dark:aria-invalid:focus:ring-danger-400/30 px-3.5 py-2.5 text-sm"
x-ref="trigger"
type="button"
aria-haspopup="listbox"
aria-controls="searchable-invalid-panel"
aria-expanded="false"
x-bind:aria-invalid="showError ? 'true' : null"
x-bind:aria-required="required ? 'true' : null"
x-bind:disabled="disabled"
x-on:click="onTrigger()"
x-on:keydown.down.prevent="onArrow()"
x-bind:aria-describedby="[showError ? 'searchable-invalid-error' : null].filter(Boolean).join(' ') || null"
aria-labelledby="searchable-invalid-label searchable-invalid-value"
>
<span
id="searchable-invalid-value"
x-bind:class="hasValue ? '' : 'text-dominant-600 dark:text-dominant-400'"
data-placeholder="Select a country"
x-text="hasValue ? selected[0].text : $el.dataset.placeholder"
class="block truncate"
>Select a country</span
>
</button>
<button
type="button"
aria-label="Clear Error from the server"
x-bind:hidden="!hasValue || disabled"
x-on:click="clear()"
class="absolute top-1/2 right-9 flex items-center justify-center size-6 text-xs text-dominant-600 dark:text-dominant-300 rounded-full cursor-pointer transition-colors -translate-y-1/2 hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
<i
aria-hidden="true"
class="absolute top-1/2 right-3.5 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-chevron-down"
>
</i>
</div>
<div
id="searchable-invalid-panel"
class="absolute z-10 mt-1 w-full bg-white dark:bg-dominant-800 rounded-lg border border-dominant-200 dark:border-dominant-700 opacity-0 shadow-lg invisible origin-top scale-95 transition-all duration-150 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:visible group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:scale-100 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:opacity-100"
>
<div class="p-2 border-b border-dominant-200 dark:border-dominant-700">
<div class="relative">
<i
aria-hidden="true"
class="absolute top-1/2 left-3 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-magnifying-glass"
>
</i>
<input
x-ref="search"
x-model="query"
type="text"
role="combobox"
autocomplete="off"
aria-autocomplete="list"
aria-expanded="true"
aria-controls="searchable-invalid-list"
x-bind:aria-activedescendant="activeId"
aria-label="Search Error from the server"
placeholder="Search…"
x-on:input="onInput()"
x-on:keydown.down.prevent="move(1)"
x-on:keydown.up.prevent="move(-1)"
x-on:keydown.enter.prevent="onEnter()"
class="block inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 px-3 py-1.5 pl-9 w-full text-dominant-900 dark:text-white text-sm bg-white dark:bg-dominant-950 rounded-lg placeholder:text-dominant-600 dark:placeholder:text-dominant-400 focus:inset-ring-primary-500 dark:focus:inset-ring-primary-400 focus:ring-2 focus:ring-primary-500/30 dark:focus:ring-primary-400/30 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50"
/>
</div>
</div>
<div x-ref="scroller" x-on:scroll="onScroll($event)" class="overflow-y-auto max-h-60">
<ul
id="searchable-invalid-list"
role="listbox"
aria-labelledby="searchable-invalid-label"
class="p-1"
>
<template x-for="(option, index) in visible" x-bind:key="option.value">
<li
role="option"
x-bind:id="optionId(index)"
x-bind:aria-selected="String(isSelected(option))"
x-on:click="choose(option)"
x-on:mousemove="active = index"
x-bind:class="index === active ? 'bg-dominant-100 dark:bg-dominant-700' : ''"
class="flex items-center gap-3 px-3 py-2 text-sm text-dominant-900 dark:text-dominant-100 rounded-md cursor-pointer"
>
<span class="flex-1 min-w-0">
<span x-text="option.text" class="block truncate"> </span>
<template x-if="option.description">
<span
x-text="option.description"
class="block truncate text-xs text-dominant-600 dark:text-dominant-200"
>
</span>
</template>
</span>
<template x-if="isSelected(option)">
<i
aria-hidden="true"
class="text-xs text-dominant-900 dark:text-white fa-solid fa-check"
>
</i>
</template>
</li>
</template>
</ul>
<p
x-bind:hidden="!message"
class="flex items-center gap-2 px-3 py-2 text-sm text-dominant-600 dark:text-dominant-300"
>
<i
x-bind:hidden="!loading"
aria-hidden="true"
class="text-xs fa-solid fa-spinner fa-spin"
>
</i>
<span x-text="message"> </span>
<button
id="searchable-invalid-retry"
type="button"
x-bind:hidden="!error"
x-on:click="retry()"
class="font-semibold rounded underline-offset-2 focus-visible:ring-2 focus-visible:outline-none cursor-pointer text-primary-700 dark:text-primary-300 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 underline hover:text-primary-800 dark:hover:text-primary-200 ml-auto"
>
<span>Try again</span>
</button>
</p>
</div>
<p role="status" x-text="status" class="sr-only"></p>
</div>
<select
id="searchable-invalid-select"
name="country"
x-ref="select"
tabindex="-1"
aria-hidden="true"
required="true"
x-on:invalid.prevent="onInvalid($event)"
class="sr-only"
>
<option value="ca">Canada</option>
<option value="de">Germany</option>
<option value="jp">Japan</option>
<template x-if="!multiple">
<option value x-bind:selected="!hasValue"></option>
</template>
<template x-for="item in selected" x-bind:key="item.value">
<option x-bind:value="item.value" selected x-text="item.text"></option>
</template>
</select>
<template x-if="showError">
<p
id="searchable-invalid-error"
class="flex items-start gap-1.5 mt-1.5 text-sm font-medium text-danger-700 dark:text-danger-300"
>
<i aria-hidden="true" class="mt-0.5 fa-solid fa-circle-exclamation"> </i>
<span>We do not ship to this country yet. Choose another one.</span>
</p>
</template>
</div>
</div>
<div class="min-h-44">
<div
id="searchable-loading-field"
x-data="searchableSelect(Object.assign({}, { open: true, request: () => new Promise(() => {}) }))"
x-on:focusout="onFocusOut($event)"
class="relative group/combo"
>
<div class="flex items-center gap-1 mb-1.5">
<label
id="searchable-loading-label"
for="searchable-loading"
class="block text-sm font-medium text-dominant-700 dark:text-dominant-200"
>
<span>Loading</span>
</label>
</div>
<div class="relative">
<button
id="searchable-loading"
class="block inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 pr-16 w-full text-dominant-900 dark:text-white text-left bg-white dark:bg-dominant-950 rounded-lg cursor-pointer placeholder:text-dominant-600 dark:placeholder:text-dominant-400 focus:inset-ring-primary-500 dark:focus:inset-ring-primary-400 focus:ring-2 focus:ring-primary-500/30 dark:focus:ring-primary-400/30 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:inset-ring-danger-600 dark:aria-invalid:inset-ring-danger-400 aria-invalid:focus:inset-ring-danger-600 dark:aria-invalid:focus:inset-ring-danger-400 aria-invalid:focus:ring-danger-600/30 dark:aria-invalid:focus:ring-danger-400/30 px-3.5 py-2.5 text-sm"
x-ref="trigger"
type="button"
aria-haspopup="listbox"
aria-controls="searchable-loading-panel"
aria-expanded="false"
x-bind:aria-invalid="showError ? 'true' : null"
x-bind:aria-required="required ? 'true' : null"
x-bind:disabled="disabled"
x-on:click="onTrigger()"
x-on:keydown.down.prevent="onArrow()"
x-bind:aria-describedby="[showError ? 'searchable-loading-error' : null].filter(Boolean).join(' ') || null"
aria-labelledby="searchable-loading-label searchable-loading-value"
>
<span
id="searchable-loading-value"
x-bind:class="hasValue ? '' : 'text-dominant-600 dark:text-dominant-400'"
data-placeholder="Search countries…"
x-text="hasValue ? selected[0].text : $el.dataset.placeholder"
class="block truncate"
>Search countries…</span
>
</button>
<button
type="button"
aria-label="Clear Loading"
x-bind:hidden="!hasValue || disabled"
x-on:click="clear()"
class="absolute top-1/2 right-9 flex items-center justify-center size-6 text-xs text-dominant-600 dark:text-dominant-300 rounded-full cursor-pointer transition-colors -translate-y-1/2 hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
<i
aria-hidden="true"
class="absolute top-1/2 right-3.5 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-chevron-down"
>
</i>
</div>
<div
id="searchable-loading-panel"
class="absolute z-10 mt-1 w-full bg-white dark:bg-dominant-800 rounded-lg border border-dominant-200 dark:border-dominant-700 opacity-0 shadow-lg invisible origin-top scale-95 transition-all duration-150 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:visible group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:scale-100 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:opacity-100"
>
<div class="p-2 border-b border-dominant-200 dark:border-dominant-700">
<div class="relative">
<i
aria-hidden="true"
class="absolute top-1/2 left-3 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-magnifying-glass"
>
</i>
<input
x-ref="search"
x-model="query"
type="text"
role="combobox"
autocomplete="off"
aria-autocomplete="list"
aria-expanded="true"
aria-controls="searchable-loading-list"
x-bind:aria-activedescendant="activeId"
aria-label="Search Loading"
placeholder="Search…"
x-on:input="onInput()"
x-on:keydown.down.prevent="move(1)"
x-on:keydown.up.prevent="move(-1)"
x-on:keydown.enter.prevent="onEnter()"
class="block inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 px-3 py-1.5 pl-9 w-full text-dominant-900 dark:text-white text-sm bg-white dark:bg-dominant-950 rounded-lg placeholder:text-dominant-600 dark:placeholder:text-dominant-400 focus:inset-ring-primary-500 dark:focus:inset-ring-primary-400 focus:ring-2 focus:ring-primary-500/30 dark:focus:ring-primary-400/30 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50"
/>
</div>
</div>
<div x-ref="scroller" x-on:scroll="onScroll($event)" class="overflow-y-auto max-h-60">
<ul
id="searchable-loading-list"
role="listbox"
aria-labelledby="searchable-loading-label"
class="p-1"
>
<template x-for="(option, index) in visible" x-bind:key="option.value">
<li
role="option"
x-bind:id="optionId(index)"
x-bind:aria-selected="String(isSelected(option))"
x-on:click="choose(option)"
x-on:mousemove="active = index"
x-bind:class="index === active ? 'bg-dominant-100 dark:bg-dominant-700' : ''"
class="flex items-center gap-3 px-3 py-2 text-sm text-dominant-900 dark:text-dominant-100 rounded-md cursor-pointer"
>
<span class="flex-1 min-w-0">
<span x-text="option.text" class="block truncate"> </span>
<template x-if="option.description">
<span
x-text="option.description"
class="block truncate text-xs text-dominant-600 dark:text-dominant-200"
>
</span>
</template>
</span>
<template x-if="isSelected(option)">
<i
aria-hidden="true"
class="text-xs text-dominant-900 dark:text-white fa-solid fa-check"
>
</i>
</template>
</li>
</template>
</ul>
<p
x-bind:hidden="!message"
class="flex items-center gap-2 px-3 py-2 text-sm text-dominant-600 dark:text-dominant-300"
>
<i
x-bind:hidden="!loading"
aria-hidden="true"
class="text-xs fa-solid fa-spinner fa-spin"
>
</i>
<span x-text="message"> </span>
<button
id="searchable-loading-retry"
type="button"
x-bind:hidden="!error"
x-on:click="retry()"
class="font-semibold rounded underline-offset-2 focus-visible:ring-2 focus-visible:outline-none cursor-pointer text-primary-700 dark:text-primary-300 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 underline hover:text-primary-800 dark:hover:text-primary-200 ml-auto"
>
<span>Try again</span>
</button>
</p>
</div>
<p role="status" x-text="status" class="sr-only"></p>
</div>
<select
id="searchable-loading-select"
name="loading"
x-ref="select"
tabindex="-1"
aria-hidden="true"
x-on:invalid.prevent="onInvalid($event)"
class="sr-only"
>
<template x-if="!multiple">
<option value x-bind:selected="!hasValue"></option>
</template>
<template x-for="item in selected" x-bind:key="item.value">
<option x-bind:value="item.value" selected x-text="item.text"></option>
</template>
</select>
<template x-if="showError">
<p
id="searchable-loading-error"
class="flex items-start gap-1.5 mt-1.5 text-sm font-medium text-danger-700 dark:text-danger-300"
>
<i aria-hidden="true" class="mt-0.5 fa-solid fa-circle-exclamation"> </i>
<span>Select an option.</span>
</p>
</template>
</div>
</div>
<div class="min-h-44">
<div
id="searchable-empty-field"
x-data="searchableSelect(Object.assign({}, { open: true, request: () => new Promise((resolve) => setTimeout(() => resolve({ items: [], nextPage: null }), 600)) }))"
x-on:focusout="onFocusOut($event)"
class="relative group/combo"
>
<div class="flex items-center gap-1 mb-1.5">
<label
id="searchable-empty-label"
for="searchable-empty"
class="block text-sm font-medium text-dominant-700 dark:text-dominant-200"
>
<span>Empty</span>
</label>
</div>
<div class="relative">
<button
id="searchable-empty"
class="block inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 pr-16 w-full text-dominant-900 dark:text-white text-left bg-white dark:bg-dominant-950 rounded-lg cursor-pointer placeholder:text-dominant-600 dark:placeholder:text-dominant-400 focus:inset-ring-primary-500 dark:focus:inset-ring-primary-400 focus:ring-2 focus:ring-primary-500/30 dark:focus:ring-primary-400/30 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:inset-ring-danger-600 dark:aria-invalid:inset-ring-danger-400 aria-invalid:focus:inset-ring-danger-600 dark:aria-invalid:focus:inset-ring-danger-400 aria-invalid:focus:ring-danger-600/30 dark:aria-invalid:focus:ring-danger-400/30 px-3.5 py-2.5 text-sm"
x-ref="trigger"
type="button"
aria-haspopup="listbox"
aria-controls="searchable-empty-panel"
aria-expanded="false"
x-bind:aria-invalid="showError ? 'true' : null"
x-bind:aria-required="required ? 'true' : null"
x-bind:disabled="disabled"
x-on:click="onTrigger()"
x-on:keydown.down.prevent="onArrow()"
x-bind:aria-describedby="[showError ? 'searchable-empty-error' : null].filter(Boolean).join(' ') || null"
aria-labelledby="searchable-empty-label searchable-empty-value"
>
<span
id="searchable-empty-value"
x-bind:class="hasValue ? '' : 'text-dominant-600 dark:text-dominant-400'"
data-placeholder="Search countries…"
x-text="hasValue ? selected[0].text : $el.dataset.placeholder"
class="block truncate"
>Search countries…</span
>
</button>
<button
type="button"
aria-label="Clear Empty"
x-bind:hidden="!hasValue || disabled"
x-on:click="clear()"
class="absolute top-1/2 right-9 flex items-center justify-center size-6 text-xs text-dominant-600 dark:text-dominant-300 rounded-full cursor-pointer transition-colors -translate-y-1/2 hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
<i
aria-hidden="true"
class="absolute top-1/2 right-3.5 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-chevron-down"
>
</i>
</div>
<div
id="searchable-empty-panel"
class="absolute z-10 mt-1 w-full bg-white dark:bg-dominant-800 rounded-lg border border-dominant-200 dark:border-dominant-700 opacity-0 shadow-lg invisible origin-top scale-95 transition-all duration-150 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:visible group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:scale-100 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:opacity-100"
>
<div class="p-2 border-b border-dominant-200 dark:border-dominant-700">
<div class="relative">
<i
aria-hidden="true"
class="absolute top-1/2 left-3 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-magnifying-glass"
>
</i>
<input
x-ref="search"
x-model="query"
type="text"
role="combobox"
autocomplete="off"
aria-autocomplete="list"
aria-expanded="true"
aria-controls="searchable-empty-list"
x-bind:aria-activedescendant="activeId"
aria-label="Search Empty"
placeholder="Search…"
x-on:input="onInput()"
x-on:keydown.down.prevent="move(1)"
x-on:keydown.up.prevent="move(-1)"
x-on:keydown.enter.prevent="onEnter()"
class="block inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 px-3 py-1.5 pl-9 w-full text-dominant-900 dark:text-white text-sm bg-white dark:bg-dominant-950 rounded-lg placeholder:text-dominant-600 dark:placeholder:text-dominant-400 focus:inset-ring-primary-500 dark:focus:inset-ring-primary-400 focus:ring-2 focus:ring-primary-500/30 dark:focus:ring-primary-400/30 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50"
/>
</div>
</div>
<div x-ref="scroller" x-on:scroll="onScroll($event)" class="overflow-y-auto max-h-60">
<ul
id="searchable-empty-list"
role="listbox"
aria-labelledby="searchable-empty-label"
class="p-1"
>
<template x-for="(option, index) in visible" x-bind:key="option.value">
<li
role="option"
x-bind:id="optionId(index)"
x-bind:aria-selected="String(isSelected(option))"
x-on:click="choose(option)"
x-on:mousemove="active = index"
x-bind:class="index === active ? 'bg-dominant-100 dark:bg-dominant-700' : ''"
class="flex items-center gap-3 px-3 py-2 text-sm text-dominant-900 dark:text-dominant-100 rounded-md cursor-pointer"
>
<span class="flex-1 min-w-0">
<span x-text="option.text" class="block truncate"> </span>
<template x-if="option.description">
<span
x-text="option.description"
class="block truncate text-xs text-dominant-600 dark:text-dominant-200"
>
</span>
</template>
</span>
<template x-if="isSelected(option)">
<i
aria-hidden="true"
class="text-xs text-dominant-900 dark:text-white fa-solid fa-check"
>
</i>
</template>
</li>
</template>
</ul>
<p
x-bind:hidden="!message"
class="flex items-center gap-2 px-3 py-2 text-sm text-dominant-600 dark:text-dominant-300"
>
<i
x-bind:hidden="!loading"
aria-hidden="true"
class="text-xs fa-solid fa-spinner fa-spin"
>
</i>
<span x-text="message"> </span>
<button
id="searchable-empty-retry"
type="button"
x-bind:hidden="!error"
x-on:click="retry()"
class="font-semibold rounded underline-offset-2 focus-visible:ring-2 focus-visible:outline-none cursor-pointer text-primary-700 dark:text-primary-300 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 underline hover:text-primary-800 dark:hover:text-primary-200 ml-auto"
>
<span>Try again</span>
</button>
</p>
</div>
<p role="status" x-text="status" class="sr-only"></p>
</div>
<select
id="searchable-empty-select"
name="empty"
x-ref="select"
tabindex="-1"
aria-hidden="true"
x-on:invalid.prevent="onInvalid($event)"
class="sr-only"
>
<template x-if="!multiple">
<option value x-bind:selected="!hasValue"></option>
</template>
<template x-for="item in selected" x-bind:key="item.value">
<option x-bind:value="item.value" selected x-text="item.text"></option>
</template>
</select>
<template x-if="showError">
<p
id="searchable-empty-error"
class="flex items-start gap-1.5 mt-1.5 text-sm font-medium text-danger-700 dark:text-danger-300"
>
<i aria-hidden="true" class="mt-0.5 fa-solid fa-circle-exclamation"> </i>
<span>Select an option.</span>
</p>
</template>
</div>
</div>
<div class="min-h-44">
<div
id="searchable-http-field"
x-data="searchableSelect(Object.assign({}, { open: true, request: () => Promise.reject(new Error('HTTP 500')) }))"
x-on:focusout="onFocusOut($event)"
class="relative group/combo"
>
<div class="flex items-center gap-1 mb-1.5">
<label
id="searchable-http-label"
for="searchable-http"
class="block text-sm font-medium text-dominant-700 dark:text-dominant-200"
>
<span>HTTP error</span>
</label>
</div>
<div class="relative">
<button
id="searchable-http"
class="block inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 pr-16 w-full text-dominant-900 dark:text-white text-left bg-white dark:bg-dominant-950 rounded-lg cursor-pointer placeholder:text-dominant-600 dark:placeholder:text-dominant-400 focus:inset-ring-primary-500 dark:focus:inset-ring-primary-400 focus:ring-2 focus:ring-primary-500/30 dark:focus:ring-primary-400/30 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:inset-ring-danger-600 dark:aria-invalid:inset-ring-danger-400 aria-invalid:focus:inset-ring-danger-600 dark:aria-invalid:focus:inset-ring-danger-400 aria-invalid:focus:ring-danger-600/30 dark:aria-invalid:focus:ring-danger-400/30 px-3.5 py-2.5 text-sm"
x-ref="trigger"
type="button"
aria-haspopup="listbox"
aria-controls="searchable-http-panel"
aria-expanded="false"
x-bind:aria-invalid="showError ? 'true' : null"
x-bind:aria-required="required ? 'true' : null"
x-bind:disabled="disabled"
x-on:click="onTrigger()"
x-on:keydown.down.prevent="onArrow()"
x-bind:aria-describedby="[showError ? 'searchable-http-error' : null].filter(Boolean).join(' ') || null"
aria-labelledby="searchable-http-label searchable-http-value"
>
<span
id="searchable-http-value"
x-bind:class="hasValue ? '' : 'text-dominant-600 dark:text-dominant-400'"
data-placeholder="Search countries…"
x-text="hasValue ? selected[0].text : $el.dataset.placeholder"
class="block truncate"
>Search countries…</span
>
</button>
<button
type="button"
aria-label="Clear HTTP error"
x-bind:hidden="!hasValue || disabled"
x-on:click="clear()"
class="absolute top-1/2 right-9 flex items-center justify-center size-6 text-xs text-dominant-600 dark:text-dominant-300 rounded-full cursor-pointer transition-colors -translate-y-1/2 hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
<i
aria-hidden="true"
class="absolute top-1/2 right-3.5 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-chevron-down"
>
</i>
</div>
<div
id="searchable-http-panel"
class="absolute z-10 mt-1 w-full bg-white dark:bg-dominant-800 rounded-lg border border-dominant-200 dark:border-dominant-700 opacity-0 shadow-lg invisible origin-top scale-95 transition-all duration-150 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:visible group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:scale-100 group-has-[button[aria-haspopup=listbox][aria-expanded=true]]/combo:opacity-100"
>
<div class="p-2 border-b border-dominant-200 dark:border-dominant-700">
<div class="relative">
<i
aria-hidden="true"
class="absolute top-1/2 left-3 text-xs text-dominant-600 dark:text-dominant-300 pointer-events-none -translate-y-1/2 fa-solid fa-magnifying-glass"
>
</i>
<input
x-ref="search"
x-model="query"
type="text"
role="combobox"
autocomplete="off"
aria-autocomplete="list"
aria-expanded="true"
aria-controls="searchable-http-list"
x-bind:aria-activedescendant="activeId"
aria-label="Search HTTP error"
placeholder="Search…"
x-on:input="onInput()"
x-on:keydown.down.prevent="move(1)"
x-on:keydown.up.prevent="move(-1)"
x-on:keydown.enter.prevent="onEnter()"
class="block inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 px-3 py-1.5 pl-9 w-full text-dominant-900 dark:text-white text-sm bg-white dark:bg-dominant-950 rounded-lg placeholder:text-dominant-600 dark:placeholder:text-dominant-400 focus:inset-ring-primary-500 dark:focus:inset-ring-primary-400 focus:ring-2 focus:ring-primary-500/30 dark:focus:ring-primary-400/30 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50"
/>
</div>
</div>
<div x-ref="scroller" x-on:scroll="onScroll($event)" class="overflow-y-auto max-h-60">
<ul
id="searchable-http-list"
role="listbox"
aria-labelledby="searchable-http-label"
class="p-1"
>
<template x-for="(option, index) in visible" x-bind:key="option.value">
<li
role="option"
x-bind:id="optionId(index)"
x-bind:aria-selected="String(isSelected(option))"
x-on:click="choose(option)"
x-on:mousemove="active = index"
x-bind:class="index === active ? 'bg-dominant-100 dark:bg-dominant-700' : ''"
class="flex items-center gap-3 px-3 py-2 text-sm text-dominant-900 dark:text-dominant-100 rounded-md cursor-pointer"
>
<span class="flex-1 min-w-0">
<span x-text="option.text" class="block truncate"> </span>
<template x-if="option.description">
<span
x-text="option.description"
class="block truncate text-xs text-dominant-600 dark:text-dominant-200"
>
</span>
</template>
</span>
<template x-if="isSelected(option)">
<i
aria-hidden="true"
class="text-xs text-dominant-900 dark:text-white fa-solid fa-check"
>
</i>
</template>
</li>
</template>
</ul>
<p
x-bind:hidden="!message"
class="flex items-center gap-2 px-3 py-2 text-sm text-dominant-600 dark:text-dominant-300"
>
<i
x-bind:hidden="!loading"
aria-hidden="true"
class="text-xs fa-solid fa-spinner fa-spin"
>
</i>
<span x-text="message"> </span>
<button
id="searchable-http-retry"
type="button"
x-bind:hidden="!error"
x-on:click="retry()"
class="font-semibold rounded underline-offset-2 focus-visible:ring-2 focus-visible:outline-none cursor-pointer text-primary-700 dark:text-primary-300 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 underline hover:text-primary-800 dark:hover:text-primary-200 ml-auto"
>
<span>Try again</span>
</button>
</p>
</div>
<p role="status" x-text="status" class="sr-only"></p>
</div>
<select
id="searchable-http-select"
name="http"
x-ref="select"
tabindex="-1"
aria-hidden="true"
x-on:invalid.prevent="onInvalid($event)"
class="sr-only"
>
<template x-if="!multiple">
<option value x-bind:selected="!hasValue"></option>
</template>
<template x-for="item in selected" x-bind:key="item.value">
<option x-bind:value="item.value" selected x-text="item.text"></option>
</template>
</select>
<template x-if="showError">
<p
id="searchable-http-error"
class="flex items-start gap-1.5 mt-1.5 text-sm font-medium text-danger-700 dark:text-danger-300"
>
<i aria-hidden="true" class="mt-0.5 fa-solid fa-circle-exclamation"> </i>
<span>Select an option.</span>
</p>
</template>
</div>
</div>
</div>
Options
Every option is optional. They go in x-data="searchableSelect({ … })".
| Option | Type | Default | Description |
|---|---|---|---|
url
|
string | – |
The endpoint of a remote list. Without it the options come from <option> elements or options.
|
headers
|
object or function |
{ Accept, Content-Type } (JSON)
|
Merged over the defaults. A function may return a Promise: put tokens here. |
limit
|
number | not sent |
Items per page. Sent as limit; the server decides when it is missing.
|
filters
|
object |
{}
|
Fixed filters of this field, sent as filters[field]=value.
|
sorts
|
object |
{}
|
Fixed sorting of this field, sent as sorts[field]=asc|desc.
|
firstPage
|
number or string |
null
|
The page of the first request. null is not sent.
|
params
|
function (term, page) | page, limit, search, filters, sorts |
The query string of one request. Returns an object: an empty string is sent empty, null and undefined are not sent.
|
parse
|
function (response) | data and links.next |
Returns { items, nextPage }. nextPage: null means there is no next page.
|
map
|
function (item) | the item as it is |
Turns one item into { value, text, label?, description? }.
|
request
|
async function (term, page, signal) | – |
Replaces params, headers, fetch, parse and map. Returns { items, nextPage }; pass signal on to cancel a stale request.
|
minChars
|
number |
0
|
Characters to type before a remote search starts. |
delay
|
number (ms) |
300
|
Pause after typing before the search restarts from page 1. |
maxChips
|
number |
2
|
Multiple only: chips shown before the rest become “+N”. The box keeps the height of a single select. |
options
|
array | – |
Inline JSON options { value, text, description? } rendered by your server.
|
value
|
string or array | – | Initial value(s) of a local list. |
selected
|
array | – | Initial options of a remote list, so a saved value shows its text before the list loads. |
multiple
|
boolean | from the select | Allows several options. |