Arunachalam

Expandable Search Bar

Buttons 104

About

This expandable search bar is a sleek, animated UI element designed for modern web applications. It collapses into a compact icon for space efficiency and smoothly expands to reveal a fully functional search input with placeholder animation, auto-focus, and submission handling. Perfect for navigation headers, dashboards, or any interface needing intuitive search functionality. Built with React and Framer Motion for fluid animations, it's customizable for left/right expansion and integrates seamlessly with Tailwind CSS for styling. Enhance user engagement with keyboard support (Enter to search, Escape to close) and responsive behavior.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Expandable Search Bar to your project and fits it to your theme.

Code

How Expandable Search Bar is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

import ExpandableSearchBar from "@/components/ui/expandable-search-bar";

export default function Home() {
  return (
    <main className="min-h-screen flex flex-col items-center justify-center gap-16">
      {/* Expand right */}
      <div className="w-full max-w-xs sm:max-w-md flex flex-col items-center">
        <ExpandableSearchBar
          expandDirection="right"
          width={250}
          placeholder="Search right..."
          onSearch={q => console.log("search right", q)}
          className="w-full"
        />
      </div>

      {/* Expand left */}
      <div className="w-full max-w-xs sm:max-w-md flex flex-col items-center">
        <div className="w-full flex justify-end">
          <ExpandableSearchBar
            expandDirection="left"
            width={250}
            placeholder="Search left..."
            onSearch={q => console.log("search left", q)}
            className="w-full"
          />
        </div>
      </div>
    </main>
  );
}

Dependencies

More by Arunachalam

View all
  • Scroll media expansion hero

    Scroll media expansion hero

    11.2K
  • Profile Card Testimonial Carousel

    Profile Card Testimonial Carousel

    1.4K
  • Modern Animated Sign In

    Modern Animated Sign In

    1.2K
  • Bottom Nav Bar

    Bottom Nav Bar

    944
  • Adaptive Notch Navigation Bar

    Adaptive Notch Navigation Bar

    767
  • Toast

    Toast

    678
  • Connected Carousel

    Connected Carousel

    539
  • Animated File Tree

    Animated File Tree

    360

More in Buttons

View all
  • Texture Button

    Texture Button

    108
  • Button

    Button

    14
  • Notification Button

    Notification Button

    117
  • HeroUI Button Group

    HeroUI Button Group

    2
  • Eclipse Button

    Eclipse Button

    44
  • Button Save

    Button Save

    50
  • App Store Button

    App Store Button

    484
  • Base Button

    Base Button

    1