Overview
NSDropdownMenu is a comprehensive dropdown menu component that supports single and multi-select modes, searchable options, custom headers and footers, and various item types including options, dividers, and subheaders.
Key Features
Flexible Selection
Support for both single and multi-select modes
Built-in Search
Optional search functionality to filter options
Rich Item Types
Options, dividers, and subheaders for organized menus
Action Buttons
Optional Apply and Clear All buttons for batch selection
Import
Basic Usage
Props
Display Configuration
Whether to show the header of the dropdown menu. If false,
title, overline, and subtext will be ignored.The title text displayed in the dropdown menu header.
Small text displayed above the title in the header.
Descriptive text displayed below the title in the header.
Custom header component. If provided,
showHeader, title, overline, and subtext will be ignored.Search Configuration
Whether the dropdown menu is searchable.
Placeholder text for the search input.
Icon name for the search input.
Callback function called when the search input value changes. If not provided, a default search method filters on label and description.
Selection Configuration
Whether multiple items can be selected.
List of items to display in the dropdown menu. Can include options, dividers, and subheaders. See Item Types below.
The currently selected value(s). Single object for single-select, array for multi-select.
Callback function called when selection changes. Returns single object or array depending on
multiple prop.Action Buttons
Whether to show Apply and Clear All buttons. If true,
onChange will only be called when Apply is clicked, not on option selection.Whether to show the Clear All button (only applies when
showActionButtons is true and multiple is true).Text for the Clear All button.
Text for the Apply button.
Callback function called when the Clear All button is clicked.
Advanced Configuration
In multi-select mode without action buttons, whether to call
onChange immediately on option selection (true) or only when clicking outside (false).Callback function called when the dropdown menu is scrolled to the bottom. Useful for infinite scrolling.
Message displayed when there are no items in the dropdown.
Styling
The width of the dropdown menu.
The maximum height of the dropdown menu.
Additional CSS class names for the dropdown menu.
Inline styles for the dropdown menu.
ID attribute for the dropdown menu element.
Item Types
Theitems prop accepts an array of different item types:
Option Item
Represents a selectable option in the dropdown:Must be
NSDropdownMenuBaseItemType.OPTION.The display text for the option.
The unique value for this option.
Optional description text shown below the label.
Icon displayed on the left side of the option.
Icon displayed on the right side of the option.
Whether the option is disabled.
Whether to scroll to this item when the dropdown opens.
Subheader Item
A non-selectable header to organize sections:Must be
NSDropdownMenuBaseItemType.SUB_HEADER.The text to display in the subheader.
Divider Item
A visual separator between items:Must be
NSDropdownMenuBaseItemType.DIVIDER.Advanced Examples
Organized Menu with All Item Types
Multi-Select with Action Buttons
Custom Search Handler
Infinite Scroll
Behavior Notes
onChange Callback Timing:
- Single-select without action buttons: Called immediately when an option is clicked
- Multi-select without action buttons: Called when clicking outside the dropdown (or immediately if
applyOnOptionSelectInMultipleModeis true) - With action buttons: Called only when the Apply button is clicked
Search Behavior: When
searchable is true and no onSearchInputChange is provided, the component uses a default search method that filters items based on their label and description properties.Accessibility
The component includes proper ARIA attributes and keyboard navigation:- Use
Arrow UpandArrow Downto navigate options - Press
Enterto select an option - Press
Escapeto apply changes (when action buttons are not shown) - Search input is automatically focused when
searchableis true
Use Cases
Filter Panels
Filter Panels
Use dropdown menus to create powerful filter interfaces with multiple selection options and categories.
Tag Selection
Tag Selection
Multi-select mode is perfect for allowing users to select multiple tags or categories.
Settings Menus
Settings Menus
Data Tables
Data Tables
Provide column filtering or bulk action selection in data table interfaces.