Menu

A menu component that displays actions or options in a dropdown popup.

Overview

The Menu component displays actions or options in a popup triggered by a button. It is built on Base UI Menu primitives and supports checkboxes, radio groups, submenus, keyboard navigation, and URL-state actions.

Menu content floats at parent + 2 by default. Submenu content stays on the same surface as the parent menu content, and item highlights move one level above the menu surface. Use variant="light" to reset a menu popup to surface-1.

Usage

import { Button } from "@tilt-legal/cubitt-components/button";
import {
  Menu,
  MenuContent,
  MenuItem,
  MenuTrigger,
} from "@tilt-legal/cubitt-components/menu";
<Menu>
  <MenuTrigger render={<Button variant="secondary" />}>Open Menu</MenuTrigger>
  <MenuContent>
    <MenuItem>Profile</MenuItem>
    <MenuItem>Settings</MenuItem>
  </MenuContent>
</Menu>

Examples

With Labels

Light Content Variant

Use variant="light" when a menu should reset to surface-1 instead of floating two levels above its parent surface. Nested submenu content inherits the reset and stays on the same menu surface.

With Checkboxes

With Radio Group

With Submenu

With Groups

With Destructive Action

URL State

Trigger URL state changes by providing paramName and paramSetValue to individual MenuItem elements. This is useful for opening dialogs, sheets, or other components when a menu item is selected.

API Reference

The root component that manages menu state.

PropTypeDescription
openbooleanWhether the menu is currently open (controlled).
defaultOpenbooleanWhether the menu is initially open (uncontrolled). Defaults to false.
onOpenChange(open: boolean, eventDetails) => voidCallback fired when the open state changes.
modalbooleanWhether the menu is modal. Defaults to true.
disabledbooleanWhether the menu is disabled. Defaults to false.
openOnHoverbooleanWhether to open the menu on hover. Defaults to false.
delaynumberDelay in milliseconds before opening on hover. Defaults to 100.
closeDelaynumberDelay in milliseconds before closing on hover. Defaults to 0.
loopbooleanWhether to loop keyboard focus. Defaults to true.
orientation"horizontal" | "vertical"The visual orientation of the menu. Defaults to "vertical".

The trigger that toggles the dropdown menu.

PropTypeDescription
classNamestringAdditional CSS classes for the trigger.
renderReactElement | (props) => ReactElementAllows composing the trigger with another component. Receives props to spread.
disabledbooleanWhether the trigger is disabled. Defaults to false.

The popup container for menu items. Default root content floats at parent + 2; submenu content stays on the parent menu surface.

PropTypeDefaultDescription
variant"default" | "light""default"Use "light" to reset the popup and inherited submenu content to surface-1.
classNamestring—Additional CSS classes for the content.
align"start" | "center" | "end""center"Alignment relative to the trigger.
side"top" | "right" | "bottom" | "left""bottom"Which side of the trigger to position.
sideOffsetnumber4Distance in pixels from the trigger.
alignOffsetnumber0Offset in pixels along the alignment axis.

An individual selectable item in the menu.

PropTypeDescription
classNamestringAdditional CSS classes for the item.
disabledbooleanWhether the item is disabled. Defaults to false.
variant"destructive"Visual variant for the item. Use "destructive" for delete actions.
insetbooleanWhether to add left padding for alignment with labelled items.
closeOnClickbooleanWhether to close the menu when clicked. Defaults to true.
onClickMouseEventHandlerClick handler for the item.

URL State Props

When provided with paramName, the menu item sets URL parameters when clicked.

PropTypeDescription
paramName?stringOptional URL parameter name to set when the item is selected.
paramSetValue?stringValue written to the URL when the item is selected.
paramThrottle?numberThrottle URL updates in milliseconds.
paramDebounce?numberDebounce URL updates in milliseconds.

A menu item with a checkbox.

PropTypeDescription
classNamestringAdditional CSS classes for the checkbox item.
checkedbooleanWhether the checkbox is checked.
onCheckedChange(checked: boolean) => voidCallback fired when the checked state changes.
disabledbooleanWhether the checkbox item is disabled.

A group of radio items where only one can be selected.

PropTypeDescription
valuestringThe value of the selected radio item.
onValueChange(value: string) => voidCallback fired when the selected value changes.

An individual radio item within a radio group.

PropTypeDescription
classNamestringAdditional CSS classes for the radio item.
valuestringThe value of this radio item. Required.
disabledbooleanWhether the radio item is disabled.

A label for a section of menu items.

Use MenuGroupLabel inside MenuGroup for ordinary sections or inside MenuRadioGroup when labelling a radio option set.

PropTypeDescription
classNamestringAdditional CSS classes for the label.
insetbooleanWhether to add left padding for alignment.

A visual separator between menu items.

PropTypeDescription
classNamestringAdditional CSS classes for the separator.

Groups related menu items together.

PropTypeDescription
classNamestringAdditional CSS classes for the group.

The root component for a submenu.

PropTypeDescription
openbooleanWhether the submenu is open (controlled).
defaultOpenbooleanWhether the submenu is initially open (uncontrolled).
onOpenChange(open: boolean) => voidCallback fired when the open state changes.
disabledbooleanWhether the submenu is disabled.

The trigger item for a submenu.

PropTypeDescription
classNamestringAdditional CSS classes for the submenu trigger.
insetbooleanWhether to add left padding for alignment.
disabledbooleanWhether the submenu trigger is disabled.

A utility component for displaying keyboard shortcuts.

PropTypeDescription
classNamestringAdditional CSS classes for the shortcut display.

On this page