Skip to main content

Examples

Basic dropdown menu exampleBasic dropdown menu example

Simple dropdown menu with action items triggered by a button.

Properties

Required

bool
required
Whether the dropdown menu is currently visible. Control this with state management to show/hide the menu.
ValueChanged<bool>
required
Callback function called when the menu’s visibility changes. Use this to update your state when the menu is dismissed by clicking outside.
List<NeoDropdownMenuSection>
required
A list of sections containing the menu items. Each section groups related actions together.
Widget
required
The widget that triggers the dropdown menu. Can be any widget, but typically a button or clickable element.

Layout

double
Fixed width for the dropdown menu. If not provided, the menu will size itself to fit the content.
bool
default:"false"
Whether the dropdown should match the width of the trigger widget.
bool
default:"false"
Whether the dropdown should have a maximum height with scrolling for large lists.

Section Properties

The NeoDropdownMenuSection class represents grouped sections within the dropdown:

Required

List<NeoDropdownMenuItem>
required
A list of menu items within this section.

Content

String
The section header text. If not provided, the section will not display a header.

Layout

bool
default:"true"
Whether to show a divider line between this and other sections.

Item Properties

The NeoDropdownMenuItem class represents individual actionable menu items:

Required

String
required
The text displayed for the menu item.
VoidCallback
required
Callback function executed when the item is tapped.

Content

PhosphorIconData Function(PhosphorIconsStyle)
An optional icon to display before the label.

Styling

bool
default:"false"
Whether the item represents a destructive action. When true, the item appears with danger styling (typically red).

Best Practices

  • State Management: The menu doesn’t close automatically when items are tapped, giving you control over when to dismiss it. Typically, you’ll want to close the menu (isOpen = false) in item onTap callbacks, but you can choose to do this before or after executing your action depending on your needs.
  • Destructive Actions: Use isDanger: true for destructive actions like delete, remove, or clear operations.

Integration Notes

  • Auto Dismiss: The menu automatically closes when clicking outside the dropdown area.
  • Positioning: The menu intelligently positions itself relative to the trigger to stay within screen bounds.
Last modified on January 21, 2026