Component
Search with Autocomplete
Search input components with autocomplete dropdown suggestions
- Component
- Tailwind
- MIT
Preview
Live component
9:41 100%
devsnips.dev/library/tailwind/components/input/search-with-autocomplete/ fluid · no fixed width 100%
Install
Add to your project
npx devsnips add Tailwind/Components/Input/search-with-autocomplete Tailwind/Components/Input/search-with-autocomplete <!-- Search with Autocomplete - Dropdown -->
<div class="relative max-w-md">
<label class="block text-sm font-medium text-gray-700 mb-1">Search Country</label>
<div class="relative">
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<svg class="w-5 h-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" /></svg>
</div>
<input type="text" placeholder="Type to search..." class="w-full pl-10 pr-4 py-3 bg-white border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500" />
</div>
<div class="absolute z-10 w-full mt-1 bg-white border border-gray-200 rounded-lg shadow-lg">
<div class="p-2 hover:bg-gray-50 cursor-pointer flex items-center gap-3">
<span class="text-xl">🇺🇸</span>
<div><p class="text-sm font-medium text-gray-900">United States</p><p class="text-xs text-gray-500">North America</p></div>
</div>
<div class="p-2 hover:bg-blue-50 cursor-pointer flex items-center gap-3 bg-blue-50">
<span class="text-xl">🇬🇧</span>
<div><p class="text-sm font-medium text-gray-900">United Kingdom</p><p class="text-xs text-gray-500">Europe</p></div>
</div>
<div class="p-2 hover:bg-gray-50 cursor-pointer flex items-center gap-3">
<span class="text-xl">🇩🇪</span>
<div><p class="text-sm font-medium text-gray-900">Germany</p><p class="text-xs text-gray-500">Europe</p></div>
</div>
</div>
</div>
<!-- Search with Autocomplete - Command Palette -->
<div class="mt-6 p-6 bg-slate-900 rounded-2xl max-w-md">
<label class="block text-sm font-medium text-gray-300 mb-2">Quick Actions</label>
<div class="relative">
<div class="absolute inset-y-0 left-0 pl-4 flex items-center pointer-events-none">
<svg class="w-5 h-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" /></svg>
</div>
<input type="text" placeholder="Type a command..." class="w-full pl-10 pr-4 py-3 bg-slate-800 border border-slate-600 rounded-xl text-white placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-400" />
</div>
<div class="mt-3 space-y-1">
<div class="p-3 hover:bg-slate-800 cursor-pointer rounded-lg flex items-center gap-3">
<span class="text-gray-400">⌘</span>
<div class="flex-1"><p class="text-sm text-white">Go to Dashboard</p><p class="text-xs text-gray-500">Navigate to dashboard</p></div>
</div>
<div class="p-3 hover:bg-slate-800 cursor-pointer rounded-lg flex items-center gap-3 bg-slate-800">
<span class="text-gray-400">⌘</span>
<div class="flex-1"><p class="text-sm text-white">Create New Project</p><p class="text-xs text-gray-500">Start a new project</p></div>
</div>
</div>
</div> # Search With Autocomplete
Search input with autocomplete suggestions.
## Usage
```bash
npx devsnips add Tailwind/Components/Input/search-with-autocomplete
```
Copy from `code.html`.
## File Structure
`code.html` · `preview.html` · `metadata.json` · `README.md` 45 lines UTF-8 · LF · Spaces: 2
Continue browsing