Search Bar Animation: Expanding, Suggesting and Showing Results
How to design and animate search bars: visible vs expanding search, focus states, suggestions, loading and results, keyboard and screen reader support.
Core Takeaway
Search should usually be visible as an open box, not hidden behind an icon. Animate focus so people know they can type, show suggestions quickly without jumping the layout, indicate loading for slower results, and follow the combobox pattern so keyboard and screen reader users can use suggestions. Expanding search icons are a compromise for tight spaces.
Visible beats hidden
Nielsen Norman Group recommends showing search as an open text box on sites where search matters, because people look for the box, not a magnifying glass icon. Expanding search from an icon saves space but hides the feature. Use it in tight headers, and make the expansion fast.
States to animate
Each change should be quick and clear:
- Focus: border or shadow change, placeholder fades
- Typing: clear button appears
- Suggestions: list appears below without pushing content
- Loading: small indicator inside the field for slow searches
- No results: helpful message, not an empty list
Suggestions without jank
Overlay the suggestion list instead of pushing the page down, debounce requests so suggestions do not flicker on every keystroke, and keep transitions under about 200 ms. Highlight the matching part of each suggestion.
Accessibility
Search with suggestions is a combobox. The WAI-ARIA combobox pattern describes the roles, states and keyboard behaviour: arrow keys move through suggestions, Enter selects, Escape closes. Announce the number of results for screen reader users.
Key Principles to Remember
- Show search as an open box where it matters
- Animate focus, clear, suggestions, loading and no results
- Overlay suggestions, debounce, keep transitions short
- Follow the combobox pattern for accessibility
Frequently Asked Questions
Sources
- Search: Visible and Simple — Nielsen Norman Group
- Combobox Pattern — W3C WAI-ARIA Authoring Practices