Skip to content

Menu

The Menu component displays a dropdown menu with actions that appears when clicking on a trigger element. It provides a flexible way to create context menus, dropdowns, and action menus with support for grouping, separators, and keyboard navigation.

import {
Button,
Menu,
} from '@fintech-sandpit/ui/react';
function MyComponent() {
return (
<Menu.Root>
<Menu.Trigger asChild>
<Button colorScheme="primary">
Open Menu
</Button>
</Menu.Trigger>
<Menu.Content>
<Menu.Item value="new-file">
New File
</Menu.Item>
<Menu.Item value="new-folder">
New Folder
</Menu.Item>
<Menu.Separator />
<Menu.Item value="settings">
Settings
</Menu.Item>
</Menu.Content>
</Menu.Root>
);
}
import {
Button,
Menu,
} from '@fintech-sandpit/ui/react';
function MyComponent() {
return (
<Menu.Root>
<Menu.Trigger asChild>
<Button colorScheme="primary">
Open Menu
</Button>
</Menu.Trigger>
<Menu.Content>
<Menu.ItemGroup>
<Menu.ItemGroupLabel>
File
</Menu.ItemGroupLabel>
<Menu.Item value="new-file">
New File
</Menu.Item>
<Menu.Item value="open-file">
Open File
</Menu.Item>
</Menu.ItemGroup>
<Menu.Separator />
<Menu.ItemGroup>
<Menu.ItemGroupLabel>
Edit
</Menu.ItemGroupLabel>
<Menu.Item value="cut">
Cut
</Menu.Item>
<Menu.Item value="copy">
Copy
</Menu.Item>
<Menu.Item value="paste">
Paste
</Menu.Item>
</Menu.ItemGroup>
</Menu.Content>
</Menu.Root>
);
}
NameTypeRequiredDefaultDescription
openbooleanWhether the menu is open (controlled)
defaultOpenbooleanfalseWhether the menu is open by default (uncontrolled)
positioningPositioningOptionsPositioning options for the menu. See PositioningOptions type below.
closeOnInteractOutsidebooleantrueWhether to close on outside interaction
closeOnEscapebooleantrueWhether to close on Escape key
NameTypeRequiredDefaultDescription
asChildbooleanfalseWhen true, merges props with the child element instead of rendering a wrapper
NameArgumentsDescription
onOpenChange(details: { open: boolean }) => voidCallback fired when open state changes
type PositioningOptions = {
placement?: 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end' | 'right' | 'right-start' | 'right-end'
gutter?: number
offset?: { mainAxis?: number; crossAxis?: number }
}

The root component that manages the menu state and provides context to child components. Supports both controlled and uncontrolled usage.

The element that triggers the menu when clicked. Use asChild prop to merge props with a child element.

The main content container for the menu. Automatically includes positioning and portal rendering.

An individual menu item. Supports click handlers and disabled state.

A container for grouping related menu items together.

A label for a menu item group, typically displayed as a header above grouped items.

A visual separator between menu items or groups.