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';
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';
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>
);
NameTypeDefaultDescription
openbooleanWhether the menu is open (controlled)
defaultOpenbooleanWhether the menu is open by default (uncontrolled)
lazyMountbooleantrueWhether to lazy mount the menu content
unmountOnExitbooleantrueWhether to unmount the menu content when it is closed
placementPlacementbottom-startThe placement of the menu
offsetMainAxisnumber8The offset of the menu on the main axis, px
offsetCrossAxisnumber0The offset of the menu on the cross axis, px
NameTypeDefaultDescription
valuestringThe value of the menu item
valueTextstringThe text to display for the menu item
disabledbooleanfalseWhether the menu item is disabled
closeOnSelectbooleantrueWhether to close the menu when the menu item is selected

Applicable to Menu.Trigger, Menu.Content, Menu.Item, Menu.ItemGroup, and Menu.ItemGroupLabel.

NameTypeDefaultDescription
asChildbooleanfalseWhen true, merges props with the child element instead of rendering a wrapper
NameTypeDescription
onOpenChange(open: boolean) => voidCallback fired when the open state changes
NameTypeDescription
onSelect(value: string) => voidCallback fired when the menu item is selected
type Placement = 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end' | 'right' | 'right-start' | 'right-end'

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.