Overview
TheMenu component is a dropdown menu with customizable positioning and trigger options. It automatically closes when clicking outside and supports both predefined menu options and custom content. Features smooth animations and flexible positioning.
Basic Usage
Examples
Basic Dropdown Menu
Custom Icon Trigger
Custom Icon Element (Without Button Wrapper)
Custom Content
With Change Handler
Programmatic Control with Ref
Props
Unique identifier required for click-outside detection. Must be unique across your application.
Positioning of the dropdown menu relative to the trigger button.
bottom-right: Menu appears below trigger, aligned to the leftbottom-left: Menu appears below trigger, aligned to the righttop-right: Menu appears above trigger, aligned to the lefttop-left: Menu appears above trigger, aligned to the right
Array of menu items to display. Each option should have an
id, label, and optional icon and labelColor. Alternative to using children.Callback fired when a menu option is clicked. Receives the clicked option object.
Callback fired when menu visibility changes. Receives
true when opened, false when closed.Icon for the button trigger (lowercase prop name). Used with the internal Button component wrapper.
Icon element for custom trigger (uppercase prop name). Replaces the Button component entirely for full control over the trigger appearance.
Custom content to display inside the menu dropdown. Alternative to using the
options prop. Useful for complex menu content.Custom CSS styles to apply to the container element.
Custom CSS styles to apply to the dropdown menu container.
OptionsProps Interface
MenuRef Interface
Styling
The menu dropdown includes:- Background: White with subtle shadow
- Border: 1px solid
Color.line.soft - Border radius: 12px
- Animation: Scale and opacity transition (0.2s ease-in-out)
- Hover state:
Color.status.neutral.hoverbackground - Menu cells: 12px vertical padding, 16px horizontal padding
- Z-index: 1000
Accessibility
- The container has
role="menu"for semantic meaning - Automatically closes on outside clicks for better UX
- Keyboard navigation support through standard button interactions
- Menu cells have hover states for clear interaction feedback
TypeScript
Best Practices
- Always provide a unique
idprop to ensure proper click-outside detection - Use
labelColorsparingly, primarily for destructive actions (e.g., delete) - Choose
positionbased on available screen space to prevent clipping - Use
iconprop for simple icon changes,Iconprop for full trigger customization - Leverage the
onChangecallback for analytics or state management - Use the ref’s
close()method when you need to close the menu programmatically