Searchable Dropdown

A dropdown menu with search/filter functionality and smooth animations.

Open in v0~2.4 kB

Last updated: March 7, 2026

Select a device

Installation

npx smoothui-cli add searchable-dropdown

Features

  • Real-time search filtering with smooth transitions
  • Support for item descriptions and icons
  • Keyboard navigation (Escape to close)
  • Animated clear button for search input
  • Staggered animation for filtered results
  • Empty state message when no results found
  • Click outside to close
  • Fully accessible and customizable

Accessibility

Keyboard Interactions

KeyDescription
Enter / SpaceOpens the dropdown when the trigger button is focused, or selects the focused item
EscapeCloses the dropdown, clears the search, and returns focus to the trigger button
Arrow DownMoves focus to the next filtered item (wraps to first)
Arrow UpMoves focus to the previous filtered item (wraps to last)
HomeMoves focus to the first filtered item
EndMoves focus to the last filtered item

ARIA Attributes

AttributeElementPurpose
aria-expandedTrigger buttonIndicates whether the dropdown is open or closed
aria-haspopup="listbox"Trigger buttonIndicates the button opens a listbox
aria-labelTrigger buttonProvides an accessible name including the selected item label
role="combobox"Search inputIdentifies the search field as a combobox
aria-autocomplete="list"Search inputIndicates the input provides list-based autocomplete
aria-controlsSearch inputReferences the id of the dropdown items list
aria-expandedSearch inputIndicates the dropdown state within the combobox
aria-labelSearch inputProvides an accessible name for the search field
role="option"List itemIdentifies each item as a selectable option
aria-selectedList itemIndicates the currently selected or focused item
aria-label="Clear search"Clear buttonProvides an accessible name for the search clear action

Screen Reader

  • The trigger button announces its expanded/collapsed state and the currently selected value
  • Each option announces its label, optional description, and selected state
  • A checkmark icon includes a <title> element for screen readers
  • The clear search button is announced with its label

Reduced Motion

This component respects the prefers-reduced-motion media query via useReducedMotion from Motion. When reduced motion is preferred, dropdown open/close, search field slide-in, item stagger, and chevron rotation animations are disabled instantly.

Props

Item Props

Each item in the dropdown can have the following properties:

PropertyTypeDescription
idstring | numberUnique identifier for the item
labelstringDisplay text for the item
iconReact.ReactNodeOptional icon to display before the label
descriptionstringOptional description text below the label