Basic Dropdown

A simple dropdown menu with label, items, and change callbacks.

Open in v0~1.7 kB

Last updated: March 7, 2026

Select a size

Installation

npx smoothui-cli add basic-dropdown

Features

  • Toggleable menu with keyboard navigation
  • Customizable label and items with optional icons
  • onChange callback with selected item
  • Compact, accessible, and easy to style
  • Works with any React content

Accessibility

Keyboard Interactions

KeyDescription
Enter / SpaceOpens the dropdown when the trigger button is focused, or selects the focused item
EscapeCloses the dropdown and returns focus to the trigger button
Arrow DownMoves focus to the next item (wraps to first)
Arrow UpMoves focus to the previous item (wraps to last)
HomeMoves focus to the first item
EndMoves focus to the last 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="option"List itemIdentifies each item as a selectable option
aria-selectedList itemIndicates the currently selected or focused item
aria-labelItem buttonProvides an accessible name for each option

Screen Reader

  • The trigger button announces its expanded/collapsed state and the currently selected value
  • Each option announces its label and selected state
  • A checkmark icon includes a <title> element for screen readers

Reduced Motion

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

Props