Animated Search Bar

Intermediate

A modern, interactive search bar with smooth animations, auto-suggestions, voice search, and multiple visual styles. Perfect for websites, dashboards, and applications requiring elegant search functionality.

Live Preview

Code Implementation

HTML
<div class="search-container">
  <div class="search-header">
    <h2 class="search-title">Animated Search Bar Collection</h2>
    <p class="search-subtitle">Modern search interfaces with smooth animations and smart features</p>
  </div>
  
  <div class="search-demos">
    <!-- Classic Animated Search -->
    <div class="search-demo">
      <h3 class="demo-title">Classic Animated</h3>
      <div class="search-wrapper classic">
        <div class="search-box">
          <input type="text" class="search-input" placeholder="Search anything..." id="classicSearch">
          <button class="search-btn" type="button">
            <svg class="search-icon" width="20" height="20" viewBox="0 0 24 24" fill="none">
              <circle cx="11" cy="11" r="8" stroke="currentColor" stroke-width="2"/>
              <path d="M21 21L16.65 16.65" stroke="currentColor" stroke-width="2"/>
            </svg>
          </button>
          <div class="search-border"></div>
        </div>
      </div>
    </div>
    
    <!-- Expanding Search -->
    <div class="search-demo">
      <h3 class="demo-title">Expanding Search</h3>
      <div class="search-wrapper expanding">
        <div class="search-box">
          <button class="search-trigger" type="button">
            <svg class="search-icon" width="20" height="20" viewBox="0 0 24 24" fill="none">
              <circle cx="11" cy="11" r="8" stroke="currentColor" stroke-width="2"/>
              <path d="M21 21L16.65 16.65" stroke="currentColor" stroke-width="2"/>
            </svg>
          </button>
          <input type="text" class="search-input" placeholder="Type to search..." id="expandingSearch">
          <button class="search-close" type="button">
            <svg width="16" height="16" viewBox="0 0 24 24" fill="none">
              <path d="M18 6L6 18M6 6L18 18" stroke="currentColor" stroke-width="2"/>
            </svg>
          </button>
        </div>
      </div>
    </div>
    
    <!-- Glassmorphism Search -->
    <div class="search-demo">
      <h3 class="demo-title">Glassmorphism Style</h3>
      <div class="search-wrapper glassmorphism">
        <div class="search-box">
          <svg class="search-icon" width="20" height="20" viewBox="0 0 24 24" fill="none">
            <circle cx="11" cy="11" r="8" stroke="currentColor" stroke-width="2"/>
            <path d="M21 21L16.65 16.65" stroke="currentColor" stroke-width="2"/>
          </svg>
          <input type="text" class="search-input" placeholder="Search with style..." id="glassSearch">
          <button class="voice-btn" type="button" title="Voice Search">
            <svg width="16" height="16" viewBox="0 0 24 24" fill="none">
              <path d="M12 1C10.34 1 9 2.34 9 4V12C9 13.66 10.34 15 12 15S15 13.66 15 12V4C15 2.34 13.66 1 12 1Z" stroke="currentColor" stroke-width="2"/>
              <path d="M19 10V12C19 16.42 15.42 20 11 20H13C17.42 20 21 16.42 21 12V10" stroke="currentColor" stroke-width="2"/>
              <path d="M12 20V24" stroke="currentColor" stroke-width="2"/>
              <path d="M8 24H16" stroke="currentColor" stroke-width="2"/>
            </svg>
          </button>
        </div>
      </div>
    </div>
    
    <!-- Advanced Search with Suggestions -->
    <div class="search-demo">
      <h3 class="demo-title">Advanced with Suggestions</h3>
      <div class="search-wrapper advanced">
        <div class="search-box">
          <div class="search-input-wrapper">
            <svg class="search-icon" width="20" height="20" viewBox="0 0 24 24" fill="none">
              <circle cx="11" cy="11" r="8" stroke="currentColor" stroke-width="2"/>
              <path d="M21 21L16.65 16.65" stroke="currentColor" stroke-width="2"/>
            </svg>
            <input type="text" class="search-input" placeholder="Search with suggestions..." id="advancedSearch" autocomplete="off">
            <div class="search-actions">
              <button class="voice-btn" type="button" title="Voice Search">
                <svg width="16" height="16" viewBox="0 0 24 24" fill="none">
                  <path d="M12 1C10.34 1 9 2.34 9 4V12C9 13.66 10.34 15 12 15S15 13.66 15 12V4C15 2.34 13.66 1 12 1Z" stroke="currentColor" stroke-width="2"/>
                  <path d="M19 10V12C19 16.42 15.42 20 11 20H13C17.42 20 21 16.42 21 12V10" stroke="currentColor" stroke-width="2"/>
                  <path d="M12 20V24" stroke="currentColor" stroke-width="2"/>
                  <path d="M8 24H16" stroke="currentColor" stroke-width="2"/>
                </svg>
              </button>
              <button class="filter-btn" type="button" title="Filters">
                <svg width="16" height="16" viewBox="0 0 24 24" fill="none">
                  <polygon points="22,3 2,3 10,12.46 10,19 14,21 14,12.46" stroke="currentColor" stroke-width="2" fill="none"/>
                </svg>
              </button>
            </div>
          </div>
          <div class="suggestions-dropdown" id="suggestionsDropdown">
            <div class="suggestions-header">
              <span class="suggestions-title">Suggestions</span>
              <button class="clear-history" type="button">Clear</button>
            </div>
            <ul class="suggestions-list" id="suggestionsList">
              <li class="suggestion-item" data-value="javascript tutorials">
                <svg class="suggestion-icon" width="16" height="16" viewBox="0 0 24 24" fill="none">
                  <circle cx="12" cy="12" r="3" stroke="currentColor" stroke-width="2"/>
                  <path d="M19.4 15C19.2 15.3 19.1 15.6 19.1 16S19.2 16.7 19.4 17L20.7 18.3C20.9 18.5 20.9 18.9 20.7 19.1L19.1 20.7C18.9 20.9 18.5 20.9 18.3 20.7L17 19.4C16.7 19.6 16.4 19.7 16 19.7S15.3 19.6 15 19.4L13.7 20.7C13.5 20.9 13.1 20.9 12.9 20.7L11.3 19.1C11.1 18.9 11.1 18.5 11.3 18.3L12.6 17C12.4 16.7 12.3 16.4 12.3 16S12.4 15.3 12.6 15L11.3 13.7C11.1 13.5 11.1 13.1 11.3 12.9L12.9 11.3C13.1 11.1 13.5 11.1 13.7 11.3L15 12.6C15.3 12.4 15.6 12.3 16 12.3S16.7 12.4 17 12.6L18.3 11.3C18.5 11.1 18.9 11.1 19.1 11.3L20.7 12.9C20.9 13.1 20.9 13.5 20.7 13.7L19.4 15Z" stroke="currentColor" stroke-width="2"/>
                </svg>
                <span class="suggestion-text">javascript tutorials</span>
                <span class="suggestion-type">Popular</span>
              </li>
              <li class="suggestion-item" data-value="react components">
                <svg class="suggestion-icon" width="16" height="16" viewBox="0 0 24 24" fill="none">
                  <circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"/>
                  <path d="M8 14S9.5 16 12 16S16 14 16 14" stroke="currentColor" stroke-width="2"/>
                  <line x1="9" y1="9" x2="9.01" y2="9" stroke="currentColor" stroke-width="2"/>
                  <line x1="15" y1="9" x2="15.01" y2="9" stroke="currentColor" stroke-width="2"/>
                </svg>
                <span class="suggestion-text">react components</span>
                <span class="suggestion-type">Recent</span>
              </li>
              <li class="suggestion-item" data-value="css animations">
                <svg class="suggestion-icon" width="16" height="16" viewBox="0 0 24 24" fill="none">
                  <path d="M13 2L3 14H12L11 22L21 10H12L13 2Z" stroke="currentColor" stroke-width="2"/>
                </svg>
                <span class="suggestion-text">css animations</span>
                <span class="suggestion-type">Trending</span>
              </li>
              <li class="suggestion-item" data-value="web development">
                <svg class="suggestion-icon" width="16" height="16" viewBox="0 0 24 24" fill="none">
                  <rect x="2" y="3" width="20" height="14" rx="2" ry="2" stroke="currentColor" stroke-width="2"/>
                  <line x1="8" y1="21" x2="16" y2="21" stroke="currentColor" stroke-width="2"/>
                  <line x1="12" y1="17" x2="12" y2="21" stroke="currentColor" stroke-width="2"/>
                </svg>
                <span class="suggestion-text">web development</span>
                <span class="suggestion-type">Popular</span>
              </li>
            </ul>
          </div>
        </div>
      </div>
    </div>
  </div>
  
  <!-- Search Results Demo -->
  <div class="search-results" id="searchResults">
    <div class="results-header">
      <h3>Search Results</h3>
      <span class="results-count" id="resultsCount">0 results</span>
    </div>
    <div class="results-list" id="resultsList">
      <!-- Results will be populated here -->
    </div>
  </div>
</div>

Snippet Features

Responsive Design: Yes
Dark Mode Support: Yes
Category: search-components
Difficulty Level: Intermediate