Skip to content

Searchable Select

Accessible Tailwind CSS combobox that filters options as you type, highlights matches and supports full keyboard navigation.

Also known as: searchable dropdown, autocomplete select, select with search, filterable select, type ahead select

Tailwind CSS Selects Responsive Dark #accessible #combobox #dropdown #form #search #select

Searchable Select live demo

Open in new tab

Tailwind CSS code (HTML, CSS, JS)

A searchable select (combobox) built with Tailwind CSS and vanilla JavaScript, shown as a dark "Choose your stack" form where users filter a list of frameworks by typing. Use it instead of a native select when the list is long enough that scrolling becomes tedious: countries, time zones, team members, tags or product variants.

How it works

The root is .tss-select. Inside the form, [data-tss-combo] wraps a text input with role="combobox", a clear button (data-tss-clear), a chevron toggle (data-tss-toggle) and the floating .tss-panel. The panel holds the #tss-listbox list with role="option" items and a "no results" message marked data-tss-empty. Each option has a data-value, a color dot, the visible name in .tss-text, a short hint and a check icon that appears through the group-aria-selected:opacity-100 utility.

On DOMContentLoaded the script initializes every .tss-select, gives each option a unique id and stores its label. Typing fires the input event: options that do not contain the query get the hidden attribute, the matching part of each label is wrapped in a mark element, and the first match becomes the active option (data-active, styled with data-active:bg-cyan-400/15). The input points to it with aria-activedescendant, so focus never leaves the text field. Choosing an option writes the label into the input, the value into the hidden name="framework" field (data-tss-value) and a line into data-tss-summary. Leaving the field without choosing restores the last committed value. style.css rotates .tss-chevron and adds the tss-drop animation.

Customization

  • Add or remove li role="option" items in #tss-listbox; give each a data-value and a .tss-text label and the filter picks them up.
  • Set aria-selected="true" on one option to preselect it on page load (SvelteKit in the demo).
  • name="framework" on the data-tss-value input: rename it to match your backend field.
  • cyan utilities (focus-within:border-cyan-400, bg-cyan-400 on the submit button, text-cyan-400 on the check icon) and color: #22d3ee on mark in style.css: switch to another color to rebrand.
  • max-h-64 on #tss-listbox: show more or fewer rows before the list scrolls.
  • bg-slate-950 on .tss-select and bg-slate-900 on .tss-panel: swap for bg-white and bg-white with text-slate-900 for a light version.

Use cases

  • Country and time zone pickers: users type to filter a long list instead of scrolling a native select
  • Team member selectors: matching text is highlighted and arrow keys move between results
  • Product variant pickers: choose from many options with a clear button and no results message
  • Tag or stack choosers: selected values are written into a hidden field for form submission

Accessibility

The field follows the ARIA combobox pattern: role="combobox", aria-autocomplete="list", aria-controls, a live aria-expanded state and aria-activedescendant. The listbox is labelled by the visible label, options expose aria-selected, and a visually hidden role="status" region announces result counts and selections. Keyboard support: ArrowDown and ArrowUp open the list and move through matches, Enter selects, Escape closes (or clears the value when already closed), Tab closes without changing the value. The clear button has an sr-only label, the toggle is mouse-only and hidden from assistive technology, and the drop animation is disabled under prefers-reduced-motion.

Usage notes

The form submit is simulated; replace the handler in script.js with a fetch() call when you connect a backend. For several instances, repeat the .tss-select block with unique id values for the label, input and listbox.

Searchable Select at a glance

Framework
Tailwind CSS
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
Tailwind CSS
Layout
Responsive, works on mobile, dark design
Category
Selects
License
Free for personal and commercial use

Questions about this template

Can I use the Searchable Select code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

Load Tailwind CSS from a CDN (the links are under Requirements). Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

Add these to your page (already included in the download):

  • <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>

The Tailwind browser build is for prototyping. In production, compile Tailwind with its CLI or your bundler.

Searchable Select – free Tailwind CSS select template
Searchable Select · free Tailwind CSS select template

More Selects

Multi-Select Dropdown with Checkboxes – free Bootstrap 5 select template

Multi-Select Dropdown with Checkboxes

Bootstrap 5 multi-select dropdown with checkboxes, live search, select all and clear, a selected count badge and removable chips.

Styled Form Select Sizes – free Bootstrap 6 select template

Styled Form Select Sizes

Bootstrap 6 native selects styled with .form-control in small, default and large sizes, plus option groups, a disabled field and a multi-select with a live summary.

Multi-Select with Chips – free Bootstrap 6 select template

Multi-Select with Chips

Dark Bootstrap 6 multi-select Combobox where chosen teams appear as removable Chips, with check marks, member totals, keyboard removal and a hidden form value.

Country Select with Flags – free Bootstrap 6 select template

Country Select with Flags

Bootstrap 6 Combobox of countries with emoji flags and dial codes, searchable by name or code, feeding a phone number field and an SMS preview.

Searchable Select with Combobox – free Bootstrap 6 select template

Searchable Select with Combobox

Bootstrap 6 Combobox time zone picker with live search, grouped options, type-ahead, keyboard navigation and a local-time clock card.

Styled Native Select – free Pure CSS select template

Styled Native Select

Pure CSS restyle of the native select element with a custom arrow, focus ring, error, success and disabled states, and three sizes.