Skip to content

Autocomplete Dropdown

A copy-paste search & autocomplete component in pure HTML, CSS & vanilla JS. Zero dependencies, framework-agnostic, MIT-licensed.

Search & AutocompleteHTMLJavaScriptCSSany framework
pricing tables
private route
primary button

Copy into your project

HTML
<div class="nuda-autodrop">
  <div class="nuda-autodrop__field">
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor"
         stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
      <circle cx="11" cy="11" r="7" />
      <path d="m21 21-4.3-4.3" />
    </svg>
    <input value="pri" />
  </div>
  <div class="nuda-autodrop__list">
    <div class="nuda-autodrop__item">pricing tables</div>
    <div class="nuda-autodrop__item">private route</div>
    <div class="nuda-autodrop__item">primary button</div>
  </div>
</div>
JavaScript
const root = document.querySelector('.nuda-autodrop');
const input = root.querySelector('input');

input.addEventListener('focus', () => root.classList.add('is-open'));
input.addEventListener('blur', () => {
  // Tiny delay so click on a list item lands before close
  setTimeout(() => root.classList.remove('is-open'), 120);
});
CSS
.nuda-autodrop {
  position: relative;
  width: 100%;
  max-width: 240px;
}

.nuda-autodrop__field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(0,0,0,.3);
  border: 1px solid #e4ff54;
  border-radius: 10px;
  color: #fafafa;
  box-shadow: 0 0 0 3px rgba(228,255,84,.12);
}

.nuda-autodrop__field svg {
  width: 14px;
  height: 14px;
  color: #e4ff54;
  flex-shrink: 0;
}

.nuda-autodrop__field input {
  background: transparent;
  border: 0;
  outline: none;
  color: #fafafa;
  font-size: 13px;
  flex: 1;
  min-width: 0;
}

.nuda-autodrop__list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #111114;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  padding: 6px;
  opacity: 0;
  transform: translateY(-6px) scale(.98);
  transform-origin: top center;
  pointer-events: none;
  transition: opacity .25s,transform .3s cubic-bezier(.16,1,.3,1);
  z-index: 10;
  box-shadow: 0 12px 32px -10px rgba(0,0,0,.6);
}

.nuda-autodrop.is-open .nuda-autodrop__list {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.nuda-autodrop__item {
  padding: 8px 10px;
  border-radius: 7px;
  color: #a0a0a8;
  font-size: 12px;
  cursor: pointer;
  transition: background .15s,color .2s,padding-left .25s;
  animation: _autoIn .4s cubic-bezier(.16,1,.3,1) both;
}

.nuda-autodrop__item:hover {
  background: rgba(228,255,84,.08);
  color: #e4ff54;
  padding-left: 14px;
}

@keyframes _autoIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

How to use Autocomplete Dropdown

Paste the HTML where you need it and the CSS into a global stylesheet (or a <style> tag). Every class is prefixed nuda- so it never collides with Tailwind or your own styles. Tweak the CSS custom properties to match your design system.

Works in React, Vue, Svelte, Astro, Next.js, Nuxt, Laravel Blade, Django, Rails — or a single .html file. No npm install, no build step.

More search & autocomplete components

← Browse all NudaUI components